pe: harden call_evidence CLI input/output guards and atomic writes #2658
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2666"
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-26T01:34:21Z.
Change
Harden
tools/call_evidence.pyCLI path validation and output writing, and add a pure-Python synthetic PE32+ CLI test suite (tests/call_evidence_cli_check.py) registered inCMakeLists.txtaspe_call_evidence_cli_check(TIMEOUT 60)._write_atomic(path, content)writing UTF-8 text to a sibling temporary file and atomically replacing the target, unlinking the temporary file on any exception so failed writes leave zero.tmpfiles._validate_output(output)rejecting symlink, directory, non-regular-file, and non-directory-parent output paths upfront, along withoutput.is_relative_to(root)/output.resolve().is_relative_to(root)overlap checks._validate_inputs(root, parser)verifying each expected DLL inrootis a regular, non-symlink, readable file before invokinginspect().main(argv: Sequence[str] | None = None) -> intand update__main__toraise SystemExit(main())with zero raw tracebacks.Verification
b0e5efb4(based onupstream/main31bcd9ad)out\pe-env\Scripts\python.exe -B tests\call_evidence_cli_check.py->Ran 9 tests in 1.344s / OK(exit 0)out\pe-env\Scripts\python.exe -B tests\call_evidence_check.py->Ran 6 tests in 0.636s / OK(exit 0)out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py->form coverage checks passed(exit 0)out\pe-env\Scripts\python.exe -B tests\docs_links_check.py->Self-test passed. Checked 19 Markdown files and 510 links.(exit 0)out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py->Self-test passed. Checked 1893 tracked source, script and build/CI files: no bidirectional controls.(exit 0)_validate_outputdirectory check,_validate_inputssymlink check,_write_atomictemp unlink cleanup).dumpbinfailures, mockedPath.replace&NamedTemporaryFilefailures leaving zero.tmpfiles and preserving prior output, and Python 3.14-safe argparse checks.Evidence and follow-up
All PE32+ binaries and DXBC containers in
tests/call_evidence_cli_check.pyare synthetically generated in pure Python under the repository MIT license, with mockeddumpbindisassembly; no game files or external binaries are included. Existingtests/call_evidence_check.pyand output JSON schema are preserved.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:36:59Z.
Review: COMMENTED
Review of head
b0e5efb4(comment only).Checked:
tools/call_evidence.py: new_validate_inputs,_validate_output,_write_atomic; the report is now written via a sibling temp file and replaced atomically, and the temp file is removed on any failure.main()returns an int and__main__usesraise SystemExit(main()). Output schema is unchanged.pe_call_evidence_cli_checksits next tocall_evidence_check, same Python guard.Commands run locally (Linux, Python venv with pefile):
python3 -B tests/call_evidence_cli_check.py-> Ran 9 tests, OKpython3 -B tests/call_evidence_check.py-> Ran 6 tests, OKpython3 tests/docs_links_check.py-> passedpython3 tests/bidi_controls_check.py-> passedgit diff --check origin/main...HEAD-> cleanpass; input symlink check disabled.No blocking findings. Windows build/test results are tracked separately.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:13:41Z.
Review: COMMENTED
Review of head
bf589769(merge of main into the PR; the PR's own change is the same asb0e5efb4).What I checked:
tools/call_evidence.py: symlink/dir/non-regular/readability guards on inputs and output, output-overlap check beforeinspect(), atomic write with temp cleanup on any exception,struct.errornow reported as a clean exit 1.parser.errorstays outside the caught exception types, so exit 2 is preserved. Logic looks correct.CMakeLists.txt:pe_call_evidence_cli_checkis registered next tocall_evidence_check, TIMEOUT 60.Commands run (Linux, worktree at the exact head, pefile in a venv):
python -B tests/call_evidence_cli_check.py-> Ran 9 tests, OKpython -B tests/call_evidence_check.py-> Ran 6 tests, OKpython3 tests/docs_links_check.py-> passedpython3 tests/bidi_controls_check.py-> passedgit diff --check origin/main...HEAD-> cleanVerdict: sound. Python-only change; Windows receipt still needed before merge.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:55:17Z.
Win2025 WARP receipt for head
8a4d5e83after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
8a4d5e83b2001fdade3fd36ab52d316ee61ff6a9:--preset dev):cmake --build --preset dev -- -j 2):478.44s(configure3.96s)ctest --preset dev -R 'pe_call_evidence' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (4.03s:pe_call_evidence_cli_check3.82s)/O2(--preset release):cmake --build --preset release -- -j 2):452.99s(configure3.29s)ctest --preset release -R 'pe_call_evidence' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (3.43s:pe_call_evidence_cli_check3.22s)tests/dxcontainer_part_offsets_check.pyok (0.7s)sccache: 2565/2897 hits; wall954.2sAI-assisted; commands listed were executed locally.