find_hash_lookup: validate scan window and result limit #2206

Closed
whoalin1 wants to merge 1 commit from upstream-pr/2206 into main
whoalin1 commented 2026-11-26 05:52:58 +00:00 (Migrated from github.com)

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


Summary

  • reject a negative --window and a non-positive --top with ValueError, which the CLI already turns into a clean exit-2 error
  • clamp each PE section's declared raw size to the bytes actually present before scanning or computing section coverage
  • add synthetic regressions for direct rank() validation, CLI exit behavior, zero-window behavior and truncated raw sections

Item: TEST-FIND-HASH-LOOKUP-ARGS

This carries forward the still-uncarried fix in old-pr/9792, originally written by abnalstlll-byte, reapplied and verified on current main.

Tests

Under the local machine coordination lock:

  • before the fix, the new tests fail: negative window and non-positive top are accepted, bad CLI arguments do not produce the intended exit-2 error, and the raw-section size is not clamped
  • after the fix: python -I tests/test_find_hash_lookup.py — 10 tests, OK
  • python -m compileall -q tools/find_hash_lookup.py tests/test_find_hash_lookup.py — pass
  • git diff --check — pass

No game files or GPU.

AI-assisted with Devin.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5504807052 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2206). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-26T05:52:58Z. --- ## Summary - reject a negative `--window` and a non-positive `--top` with `ValueError`, which the CLI already turns into a clean exit-2 error - clamp each PE section's declared raw size to the bytes actually present before scanning or computing section coverage - add synthetic regressions for direct `rank()` validation, CLI exit behavior, zero-window behavior and truncated raw sections Item: TEST-FIND-HASH-LOOKUP-ARGS This carries forward the still-uncarried fix in old-pr/9792, originally written by abnalstlll-byte, reapplied and verified on current main. ## Tests Under the local machine coordination lock: - before the fix, the new tests fail: negative `window` and non-positive `top` are accepted, bad CLI arguments do not produce the intended exit-2 error, and the raw-section size is not clamped - after the fix: `python -I tests/test_find_hash_lookup.py` — 10 tests, OK - `python -m compileall -q tools/find_hash_lookup.py tests/test_find_hash_lookup.py` — pass - `git diff --check` — pass No game files or GPU. AI-assisted with Devin.
real-rusher commented 2026-11-26 10:06:23 +00:00 (Migrated from github.com)

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


Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_find_hash_lookup.py: 10 tests OK. The PR's test file against main's tools/find_hash_lookup.py: 7 failures, so the new tests fail on main and pass with the fix. compileall clean.

AI-assisted: yes (Claude Code)

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

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


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

  • tests/test_find_hash_lookup.py: 10 passed, 5 subtests passed (main: 5 passed).

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7189902307 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2206#issuecomment-7189902307). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-26T10:50:13Z. --- Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. - `tests/test_find_hash_lookup.py`: 10 passed, 5 subtests passed (main: 5 passed). (AI-assisted test run; output checked by hand.)
whoalin1 commented 2026-11-26 13:28:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-26T13:28:10Z.


Consolidated into #2203 as cherry-pick a33822ab2 to reduce review noise. The scan-window/result-limit validation and regression tests are preserved there.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7193393550 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2206#issuecomment-7193393550). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-26T13:28:10Z. --- Consolidated into #2203 as cherry-pick `a33822ab2` to reduce review noise. The scan-window/result-limit validation and regression tests are preserved there.

Pull request closed

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!2206
No description provided.