tools: validate numeric scan/probe arguments #2203

Merged
whoalin1 merged 1 commit from upstream-pr/2203 into main 2026-11-29 14:08:55 +00:00
whoalin1 commented 2026-11-26 05:41:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-26T05:41:23Z.


Summary

  • catch ValueError when parsing --waves, so --waves 32,abc follows the existing bad-argument path and exits 2
  • add a regression test requiring exit 2, the usage error and no traceback

Item: TEST-BUFFER-BOUNDS-WAVES-ARG

This carries forward the still-uncarried fix in old-pr/9807, originally written by nino-exe, reapplied and verified on current main.

Tests

Under the local machine coordination lock:

  • control from origin/main: python -I buffer_bounds_probe.py --waves 32,abc exits 1 with ValueError traceback
  • patched tree: python -I tests/test_buffer_bounds_probe.py — 6 tests, OK
  • python -m compileall -q tools/buffer_bounds_probe.py tests/test_buffer_bounds_probe.py — pass
  • git diff --check — pass

No game files or GPU.

AI-assisted with Devin.

Consolidated numeric-argument validation

This branch now also includes the small numeric CLI validation fix formerly opened as #2206: find_hash_lookup rejects a negative --window and a non-positive --top, and clamps truncated PE section sizes before scanning. The consolidation is cherry-pick a33822ab2; no additional code was written. Both changes are small argument-validation fixes with independent regression tests.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5504687187 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2203). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-26T05:41:23Z. --- ## Summary - catch `ValueError` when parsing `--waves`, so `--waves 32,abc` follows the existing bad-argument path and exits 2 - add a regression test requiring exit 2, the usage error and no traceback Item: TEST-BUFFER-BOUNDS-WAVES-ARG This carries forward the still-uncarried fix in old-pr/9807, originally written by nino-exe, reapplied and verified on current main. ## Tests Under the local machine coordination lock: - control from `origin/main`: `python -I buffer_bounds_probe.py --waves 32,abc` exits 1 with `ValueError` traceback - patched tree: `python -I tests/test_buffer_bounds_probe.py` — 6 tests, OK - `python -m compileall -q tools/buffer_bounds_probe.py tests/test_buffer_bounds_probe.py` — pass - `git diff --check` — pass No game files or GPU. AI-assisted with Devin. ## Consolidated numeric-argument validation This branch now also includes the small numeric CLI validation fix formerly opened as #2206: `find_hash_lookup` rejects a negative `--window` and a non-positive `--top`, and clamps truncated PE section sizes before scanning. The consolidation is cherry-pick `a33822ab2`; no additional code was written. Both changes are small argument-validation fixes with independent regression tests.
real-rusher commented 2026-11-26 10:06:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T10:06:31Z.


Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_buffer_bounds_probe.py: 6 tests OK. The PR's test file against main's tools/buffer_bounds_probe.py: 1 failure, so the new test fails on main and passes with the fix. compileall clean.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7188917782 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2203#issuecomment-7188917782). Originally posted by [real-rusher](https://github.com/real-rusher) on 2026-11-26T10:06:31Z. --- Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_buffer_bounds_probe.py: 6 tests OK. The PR's test file against main's tools/buffer_bounds_probe.py: 1 failure, so the new test fails on main and passes with the fix. compileall clean. AI-assisted: yes (Claude Code)
DeadlyChirp commented 2026-11-26 10:32:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-26T10:32:23Z.


Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

  • tests/test_buffer_bounds_probe.py: 6 passed (main: 5 passed).

(AI-assisted test run; output checked by hand.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7189500261 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2203#issuecomment-7189500261). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-26T10:32:23Z. --- Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. - `tests/test_buffer_bounds_probe.py`: 6 passed (main: 5 passed). (AI-assisted test run; output checked by hand.)
sodove commented 2026-11-28 09:15:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:15:04Z.


#2203 | head a33822ab20b96af571a5be25e67115919efa5c44 | python3 -I tests/test_buffer_bounds_probe.py -v, python3 -I tests/test_find_hash_lookup.py -v | red: 16 tests, 8 assertion failures | green: 16 passed | Red → green

The baseline returned the wrong CLI status for invalid numeric input and failed the scan-argument checks.

Pinned main 4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237116370 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2203#issuecomment-7237116370). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T09:15:04Z. --- #2203 | head `a33822ab20b96af571a5be25e67115919efa5c44` | `python3 -I tests/test_buffer_bounds_probe.py -v`, `python3 -I tests/test_find_hash_lookup.py -v` | red: 16 tests, 8 assertion failures | green: 16 passed | **Red → green** The baseline returned the wrong CLI status for invalid numeric input and failed the scan-argument checks. Pinned main `4938673668d807bf365b61284bf22b1ff8d02cc4`, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7236982945).
TheGeogeo commented 2026-11-29 04:50:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T04:50:25Z.


Checked a33822ab2 against main ef3299584 on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.

  • Conflict: tools/find_hash_lookup.py. ac2c3d335 (2026-11-24, "find_hash_lookup: clamp raw section sizes and validate window and top parameters") already clamps the raw section size and validates window/top, with its own wording.
  • Partly in main already, partly still needed (STALE, needs a rebase):
    • The find_hash_lookup.py part is covered by ac2c3d335.
    • The --waves fix in tools/buffer_bounds_probe.py is not: main still runs int() on each item with no try, so --waves 32,abc ends in a traceback.
    • A rebase can drop the find_hash_lookup hunks and keep buffer_bounds_probe.py with its test.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7250892341 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2203#issuecomment-7250892341). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T04:50:25Z. --- Checked `a33822ab2` against `main` `ef3299584` on Windows 11 10.0.26300: it does not merge (`git merge-tree --write-tree`), so I ran no tests. - Conflict: `tools/find_hash_lookup.py`. `ac2c3d335` (2026-11-24, "find_hash_lookup: clamp raw section sizes and validate window and top parameters") already clamps the raw section size and validates `window`/`top`, with its own wording. - Partly in `main` already, partly still needed (STALE, needs a rebase): - The `find_hash_lookup.py` part is covered by `ac2c3d335`. - The `--waves` fix in `tools/buffer_bounds_probe.py` is not: `main` still runs `int()` on each item with no `try`, so `--waves 32,abc` ends in a traceback. - A rebase can drop the `find_hash_lookup` hunks and keep `buffer_bounds_probe.py` with its test. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 14:19:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:19:06Z.


Merged at head ccb3726. Tested by others on earlier heads: real-rusher (Ubuntu 24.04) and sodove (WSL), the new test fails on main and passes with the PR; DeadlyChirp (Windows 11) 6/6. Gap: nobody re-ran it on ccb3726 after the find_hash_lookup rebase. Could someone run python -I tests/test_buffer_bounds_probe.py and tests/test_find_hash_lookup.py on current main and post the result? AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257209210 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2203#issuecomment-7257209210). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:19:06Z. --- Merged at head ccb3726. Tested by others on earlier heads: real-rusher (Ubuntu 24.04) and sodove (WSL), the new test fails on main and passes with the PR; DeadlyChirp (Windows 11) 6/6. Gap: nobody re-ran it on ccb3726 after the find_hash_lookup rebase. Could someone run `python -I tests/test_buffer_bounds_probe.py` and `tests/test_find_hash_lookup.py` on current main and post the result? AI-assisted: yes.
TheGeogeo commented 2026-11-29 14:46:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:46:30Z.


Re-checked after the merge, on main bd643e46e (Windows 11 10.0.26300, Python 3.12.4, CPU only): passes on main.

  • python -I tests/test_buffer_bounds_probe.py: 6 tests OK.
  • python -I tests/test_find_hash_lookup.py: 14 tests OK.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257565683 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2203#issuecomment-7257565683). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T14:46:30Z. --- Re-checked after the merge, on `main` `bd643e46e` (Windows 11 10.0.26300, Python 3.12.4, CPU only): passes on main. - `python -I tests/test_buffer_bounds_probe.py`: 6 tests OK. - `python -I tests/test_find_hash_lookup.py`: 14 tests OK. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2203
No description provided.