find_hash_lookup: clamp raw section sizes and validate window and top parameters (OLD-9792) #696

Closed
abnalstlll-byte wants to merge 1 commit from upstream-pr/696 into main
abnalstlll-byte commented 2026-11-24 12:17:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T12:17:05Z.


Related issues: #14, #17, #18 (restoring old upstream PR 9792, author restoration for draft PR #70).

What and why

Restores original pull request OLD-9792 authored by @abnalstlll-byte:

  • Enforces strict section size clamping in \ ools/find_hash_lookup.py\ to prevent out-of-bounds slicing on truncated PE sections.
  • Validates --window\ and --top\ parameters against non-positive integers, returning clear command-line error messages.
  • Comprehensive unit test coverage in \ ests/test_find_hash_lookup.py\ (12/12 PASS).

Tested

  • Windows 11 x64, Python 3.14 / 3.12:
    • \python -I tests/test_find_hash_lookup.py: 12/12 PASS.
    • \python -I scripts/check_no_game_data.py\ on changed files: PASS.
  • Clean merge against \ubi/main\ (0 conflicts).

Checklist

  • No proprietary payloads, game-derived files, keys, or protection workarounds.
  • Standard library only (\python -I).
  • Preserves author attribution and original PR commit provenance.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5471977550 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/696). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T12:17:05Z. --- Related issues: #14, #17, #18 (restoring old upstream PR 9792, author restoration for draft PR #70). ### What and why Restores original pull request **OLD-9792** authored by @abnalstlll-byte: - Enforces strict section size clamping in \ ools/find_hash_lookup.py\ to prevent out-of-bounds slicing on truncated PE sections. - Validates \--window\ and \--top\ parameters against non-positive integers, returning clear command-line error messages. - Comprehensive unit test coverage in \ ests/test_find_hash_lookup.py\ (12/12 PASS). ### Tested - Windows 11 x64, Python 3.14 / 3.12: - \python -I tests/test_find_hash_lookup.py\: 12/12 PASS. - \python -I scripts/check_no_game_data.py\ on changed files: PASS. - Clean merge against \ubi/main\ (0 conflicts). ### Checklist - [x] No proprietary payloads, game-derived files, keys, or protection workarounds. - [x] Standard library only (\python -I\). - [x] Preserves author attribution and original PR commit provenance.
abnalstlll-byte commented 2026-11-25 21:34:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T21:34:51Z.


Rebased cleanly onto latest \main\ (\e34ff17e9), clearing stale base CI failures. Verified: all 12 tests in \ est_find_hash_lookup.py\ pass.

AI-assisted (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7175265932 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/696#issuecomment-7175265932). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T21:34:51Z. --- Rebased cleanly onto latest \main\ (\e34ff17e9\), clearing stale base CI failures. Verified: all 12 tests in \ est_find_hash_lookup.py\ pass. AI-assisted (Claude Code)
MoonEyes commented 2026-11-27 23:36:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T23:36:16Z.


Thanks for this, @abnalstlll-byte. #1268, opened by wetw0rks-c0ding for the same item (OLD-9792), contains your commit unchanged as its first commit and adds one commit on top: exact assertions for the section-size clamp and for the rank() argument errors (the truncation test here accepts any outcome), and rank() errors that name the parameter while the CLI still prints --window and --top. Both pull requests change the same two files, so nothing from this one is lost, and your authorship is kept in #1268.

I am closing this one to avoid two pull requests for one item. Please continue in #1268, or reopen this one if something is missing there.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230267659 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/696#issuecomment-7230267659). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T23:36:16Z. --- Thanks for this, @abnalstlll-byte. #1268, opened by `wetw0rks-c0ding` for the same item (OLD-9792), contains your commit unchanged as its first commit and adds one commit on top: exact assertions for the section-size clamp and for the `rank()` argument errors (the truncation test here accepts any outcome), and `rank()` errors that name the parameter while the CLI still prints `--window` and `--top`. Both pull requests change the same two files, so nothing from this one is lost, and your authorship is kept in #1268. I am closing this one to avoid two pull requests for one item. Please continue in #1268, or reopen this one if something is missing there. AI-assisted (Claude Code, Claude Opus 5.5)

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