pe: harden call_evidence CLI and import guards and add unit suite #1914
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1921"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T21:17:31Z.
Change
Harden
tools/call_evidence.pyagainst missing import directories, malformed or non-ASCII import names, and invalid CLI inputs, and add a synthetic PE32+ unit and refusal test suite intests/call_evidence_check.pyregistered inCMakeLists.txt:DIRECTORY_ENTRY_IMPORT,desc.imports,desc.dll, andimp.nameininspect()usinggetattr(..., None) or ()anddecode("ascii", "replace").main(argv=None)to accept an explicit argument list, validate directory resolution (OSError,is_dir()), verify all three expected DLL names exist before inspection, exit cleanly viaparser.exit(1, ...)onOSError,ValueError,pefile.PEFormatError, orsubprocess.SubprocessError, and return0.tests/call_evidence_check.pywith synthetic PE32+ builders and mockeddumpbin /nologo /disasm:nobytesoutput covering instruction reference parsing, IAT call/jmp sites with upstream callers, mapped DXBC/RTS0/DXIL containers and overlay exclusion, missing import directory and non-ASCII import names,_mapped_rva()bounds/slack rejection, end-to-endmain()JSON output, and clean CLI error exit codes without tracebacks.call_evidence_checkinCMakeLists.txt.Verification
Verified on rebased branch
pe/call-evidence-validation(on top ofupstream/main67a240ba):cmake --preset dev->Configuring done (0.2s),Total Tests: 1200(#1181: call_evidence_check)cmake --preset release->Configuring done (0.2s),Total Tests: 1200(#1181: call_evidence_check)ctest --preset dev --no-tests=error -R "^call_evidence_check$" -V->1/1passed (Ran 6 tests in 0.583s)ctest --preset release --no-tests=error -R "^call_evidence_check$" -V->1/1passed (Ran 6 tests in 0.575s)python -B tests/call_evidence_check.py -v->Ran 6 tests in 0.578s,OKpython -B tests/form_coverage_check.py->form coverage checks passedpython -B tests/docs_links_check.py->Checked 18 Markdown files and 385 links.python -B tests/bidi_controls_check.py->Checked 1346 tracked source, script and build/CI files: no bidirectional controls.Evidence and follow-up
All fixtures in
tests/call_evidence_check.pyare constructed synthetically in memory using standard Pythonstructand mockeddumpbindisassembly strings; no game binaries, dumps, or secrets are included.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:22:16Z.
Review: COMMENTED
Review of
435a15f20f4f064375eadecd0b47704c9e736260(comment only, no approval). No earlier review on this PR.Verdict: no P1/P2 found. Three P3 test gaps below.
Read: the full diff vs
origin/main(tools/call_evidence.py, the newtests/call_evidence_check.py, one CMake line). The CLI changes are bounded: a missing path, a non-directory, a missing image and an overlapping report directory each end inparser.error(exit 2, no traceback); read and parse errors end in exit 1 with a one-line message. Non-ASCII import names are decoded withreplace, so they never match the experiment table and cannot crash the run. The synthetic PE32+ builder and the DXBC fixtures are built in the test, not taken from a title.Commands run locally (Linux,
pefile==2024.8.26in a temporary venv;dumpbinis mocked in the test):git diff --check origin/main...HEAD: cleanpython -B tests/call_evidence_check.py: 6 tests OKpython3 tests/docs_links_check.py: 385 links OK;python3 tests/bidi_controls_check.py: no bidirectional controlsMutations on
tools/call_evidence.py(each reverted withgit checkout -- ., tree clean afterwards):pe.DIRECTORY_ENTRY_IMPORT): killed (4 errors)if not root.is_dir()disabled: survivedexcept (OSError, ValueError, pefile.PEFormatError, subprocess.SubprocessError)narrowed toValueError: survivedP3 (test gaps, not defects):
tools/call_evidence.py(symbol-name decode): the non-ASCII test does not fail when the decode is strict, so it does not yet prove the fixture reaches that line.tools/call_evidence.py(root.is_dir()): the "path is a file" case still exits 2 through the missing-image check, so the dedicated guard has no test of its own.tools/call_evidence.py(theexceptaroundinspect): no test makesinspectraise, so the exit-1 path and its message are untested.Not run: the real
dumpbin /disasmoutput (Windows only). The tests feed a hand-written disassembly format, so a change in thedumpbintext format would not be caught here.AI-assisted; commands listed were executed locally.
upstream-sync referenced this pull request2026-11-25 00:04:55 +00:00