pe: extract main(argv) and add directory and struct.error guards in pe_authentihash with CLI suite #2585
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2593"
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-25T22:15:21Z.
Summary
Extracts a testable
main(argv=None) -> intentrypoint intools/pe_authentihash.py, validates upfront that the target image is a regular file (rejecting directories and non-regular paths cleanly), and catchesstruct.erroralongside(OSError, ValueError)with zero raw tracebacks, backed by a standalone pure-Python CLI test suite registered in CTest.Changes
tools/pe_authentihash.py:main(argv=None) -> intforwardingargvtoparser.parse_args(argv)and returning0, invokingraise SystemExit(main())under__main__.args.image.is_dir()andnot args.image.is_file()checks before opening or mapping the input image.main()exception handling to(OSError, ValueError, struct.error)viaparser.exit(1, f"{args.image}: {error}\n")with zero raw tracebacks, preserving read-only behavior, the 0-bytemmapfallback, and exact hex digest stdout.tests/pe_authentihash_cli_check.py:mmapfallback, directory/missing/non-regular/truncated inputs,sys.argv/__main__entrypoints, andOSError/ValueError/struct.errorguards.CMakeLists.txt:pe_authentihash_cli_checkin CTest right afterpe_authentihash_oracle.Verification
All commands executed after rebasing onto
upstream/main(826b7347):out/pe-env/Scripts/python.exe -B tests/pe_authentihash_cli_check.py -vRan 5 tests in 1.080s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/pe_authentihash_check.pyRan 12 tests in 0.361s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.pyform coverage checks passed(exit 0)out/pe-env/Scripts/python.exe -B tests/docs_links_check.pySelf-test passed. Checked 19 Markdown files and 495 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.pySelf-test passed. Checked 1819 tracked source, script and build/CI files: no bidirectional controls.(exit 0)argvforwarding,is_dir(),is_file(), 0-bytemmapfallback,OSError/ValueError/struct.errorcatches,main()return code, and__main__SystemExit): 9/9 killed.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:17:05Z.
Review: COMMENTED
Review of head
5ee1a811(comment only).Verdict: sound, no blocking findings.
What I checked
tools/pe_authentihash.py:main(argv=None) -> int,parse_args(argv),raise SystemExit(main()). Behavior on the happy path is unchanged (same digest on stdout, read-only, 0-byte mmap fallback kept).is_dir()/is_file()checks run inside the existingtry, so they exit 1 with<path>: <message>and no traceback.struct.erroris now caught next toOSError/ValueError, so truncated headers give a clean exit 1.CMakeLists.txt:pe_authentihash_cli_checkregistered inside theINTAKE_PYTHONblock right afterpe_authentihash_oracle. It needs no shim target, so no skip code is needed.Commands executed (Linux, clean worktree at the head)
python3 tests/pe_authentihash_cli_check.py-> 5 tests OKpython3 tests/docs_links_check.py-> pass;python3 tests/bidi_controls_check.py-> passgit diff --check origin/main...HEAD-> cleanstruct.errorfrom the except tuple -> the new suite fails (errors=1)is_dir()check -> the new suite fails (failures=1)Not a startup/game change; no executable claims are made here. Win2025 receipt and CI are still needed before merge.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:27:44Z.
Win2025 WARP receipt for head
3b12eb35after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
3b12eb35ee8e96da96a9dbf34e93bfd4e70a520a:--preset dev):cmake --build --preset dev -- -j 2):183.17s(configure2.43s)ctest --preset dev -R 'pe_authentihash' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (2.07s:pe_authentihash_oracle0.34s,pe_authentihash0.65s,pe_authentihash_cli_check1.56s)/O2(--preset release):cmake --build --preset release -- -j 2):241.84s(configure2.81s)ctest --preset release -R 'pe_authentihash' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (1.55s:pe_authentihash_oracle0.26s,pe_authentihash0.47s,pe_authentihash_cli_check1.11s)tests/pe_authentihash_check.pyok (0.5s),tests/pe_authentihash_cli_check.pyok (1.1s)sccache: 239/557 hits; wall451.6sAI-assisted; commands listed were executed locally.