Repository navigation
find_hash_lookup: preserve input when JSON report aliases it - #4734
illusionart453-max wants to merge 1 commit into
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 40ac5f600 on Windows 11: pytest tests/test_find_hash_lookup.py -q -> 5 passed, 3 subtests passed; git diff --check clean.
find_hash_lookup now refuses a JSON report path that aliases the input image (same path, .., links), so the diagnostic cannot overwrite the artifact it is reading; the added subtest covers the alias and the ordinary output. No blocking issue.
|
Tested head
All pass. AI-assisted (Devin). |
|
Verified at head 40ac5f6 merged with current main: tests/test_find_hash_lookup.py 5/5 OK under python -I; the samefile guard covers self, dot-path and hardlink aliases and returns the tool's existing rc-2 error shape from inside the OSError handler, so a missing exe still errors cleanly. Confirmed hunk-disjoint from the pending #4882 change in the same tool — merge-tree of the two is clean. No CI checks scheduled on the branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested
|
|
Checked head
The same happens for the Suggestion: drop the code hunk and keep the test with the assertion changed to No game data, no GPU. AI-assisted. |
When --json names the executable being scanned, find_hash_lookup.py reads the executable and then replaces it with its JSON report. A different path to the same file, including a hard link, has the same effect.
Reject an existing report path that os.path.samefile identifies as the input before scanning or opening the report for writing. The CLI returns 2 and explains the collision. Regression tests use a synthetic PE and check that direct paths, normalized aliases and hard links preserve the original bytes. The existing successful-report test still passes.
Claimed as a new BUILD item (ID pending assignment)
#4683 (comment)
Tested on Windows 11 with Python 3.15.2, CPU only.
AI-assisted (Codex). Synthetic inputs only.
Depends on no other PR.