ffx: add upfront path guards and atomic writes to ffx_working_set_delta with CLI suite #2608
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2616"
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-25T23:26:09Z.
Change
Harden upfront path validation and atomic output writes in
tools/ffx_working_set_delta.pyand add a pure-Python CLI/error test suite intests/ffx_working_set_delta_cli_check.py(registered asffx_working_set_delta_cli_checkinCMakeLists.txtwithTIMEOUT 60):args.imageupfront (reject directories and missing/non-regular files) before callinggenerate().args.outputupfront (require.cppsuffix, reject symlinks, existing directories, non-directory parent/ancestors, and same-path / hardlink-samefilecollisions withargs.image).args.output.write_text(...)with sibling-temp_write_atomic(...)creating missing parent directories and unlinking the temporary file on any failure (0 leftover.tmpfiles), catching(OSError, ValueError, struct.error, pefile.PEFormatError)cleanly on stderr with no tracebacks and preserving existing tests and exit codes.AI-assisted.
Verification
Tested on commit
986d7546(rebased onupstream/main) without\pe-env\Scripts\python.exe -B:out\pe-env\Scripts\python.exe -B tests\ffx_working_set_delta_check.py -v: 7 tests OK (exit 0).out\pe-env\Scripts\python.exe -B tests\ffx_working_set_delta_cli_check.py -v: 7 tests OK (exit 0), covering nested-dir atomic.cppcreation and overwrite with 0.tmpfiles,--packageforwarding,sys.argv/__main__entrypoint, missing/directory image rejection, invalid PE bytes, non-.cpp/directory/symlink/file-parent/samefile output guards, atomic replace failure cleanup, and Python 3.14-safeargparseerrors.image.is_dir(),output.is_symlink(),output.is_dir(), andtmp_path.unlinkcleanup); 4/4 mutations killed bytests\ffx_working_set_delta_cli_check.pyand restored cleanly.out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py: passed (exit 0).out\pe-env\Scripts\python.exe -B tests\docs_links_check.py: passed (exit 0).out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py: passed (exit 0).Evidence and follow-up
All fixtures in
tests/ffx_working_set_delta_cli_check.pyare pure-Python synthetic placeholders and invalid-PE byte controls (MIT License). No existing CLI flags, exit codes, or build prerequisites changed.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:33:59Z.
Review: COMMENTED
Review of head
986d7546(comment only).Checked:
tools/ffx_working_set_delta.py: the upfront path guards (image dir/missing,.cppsuffix, symlink, directory, non-directory ancestors, same-path/samefile) and_write_atomic(sibling temp file,replace, temp unlinked on any failure). Exit codes and stderr handling are unchanged for existing callers;struct.erroris now caught cleanly.tests/ffx_working_set_delta_cli_check.pyis registered inCMakeLists.txtand guards the new behavior through the CLI.Commands run (Linux, venv with pefile):
python3 -B tests/ffx_working_set_delta_cli_check.py: 7 tests OKpython3 -B tests/ffx_working_set_delta_check.py: 7 tests OKpython3 tests/docs_links_check.py: okpython3 tests/bidi_controls_check.py: okgit diff --check origin/main...HEAD: cleanBoth mutations were reverted.
No concerns found.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:34:44Z.
Win2025 WARP receipt for head
986d7546.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
986d75468a6fb7211ff0105c93ccedc2e4f9f229:--preset dev):cmake --build --preset dev --target cpu_working_set_delta_lifted -- -j 2):1.01s(configure3.31s)ctest --preset dev -R 'ffx_working_set_delta' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (7.33s:ffx_working_set_delta_check2.66s,ffx_working_set_delta_cli_check7.12s)/O2(--preset release):cmake --build --preset release --target cpu_working_set_delta_lifted -- -j 2):7.34s(configure3.41s)ctest --preset release -R 'ffx_working_set_delta' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (4.47s:ffx_working_set_delta_check1.71s,ffx_working_set_delta_cli_check4.31s)sccache: 2/15 hits; wall26.3sAI-assisted; commands listed were executed locally.