fix(hw-oracle): protect HIP inputs from output aliases #11275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11275"
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 boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-25T23:30:03Z.
What
The standalone
tools/hw-oracle/oracle_hip.pyCLI could use one of its input files as its output path.For
--assemble SOURCE OUTPUT TARGET, choosingOUTPUT == SOURCEsuccessfully assembled and then replaced the source assembly. The dispatch form could similarly replace either the code object or the input payload. Filesystem aliases such as hard links and symlinks had the same destructive result.Reject an existing output when it is the same filesystem object as an input before invoking the HIP operation or writing output. The check deliberately uses filesystem identity rather than Windows path-object equality, so distinct files whose names differ only by case remain valid on case-sensitive Windows directories.
Input files are still read before the alias check, preserving the existing missing-input error behavior.
Tested
Windows 11, Python 3.12 and Python 3.9; WSL/Linux Python. No title or homebrew involved.
py -3 tools/hw-oracle/test_hw_oracle.py— 46 tests PASS (4 platform skips)py -3.9 tools/hw-oracle/test_hw_oracle.py— 46 tests PASS (4 platform skips)python3 tools/hw-oracle/test_hw_oracle.py— 46 tests PASS (2 platform skips)py -3 tools/check_conventions.py --base origin/main— PASSgit diff --check origin/main...HEAD— PASSpy -3 -m compileall -q tools/hw-oracle/oracle_hip.py tools/hw-oracle/test_hw_oracle.py— PASSIndependent GPT-6.1 Sol High review at submission time found one P2 in the first candidate around case-sensitive Windows directories. That was fixed by removing the resolved-path equality shortcut. The exact published patch then received a fresh narrow PASS with no findings; subsequent moving-base confirmations also found no interaction with upstream changes.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-25T23:31:26Z.
Review: COMMENTED
🟢 Approval recommended
Both CLI operations check filesystem identity before HIP work or output writes, with focused regression coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Protects the standalone HIP oracle CLI from overwriting its inputs when an output path refers to the same filesystem object.
Changes:
Review effort: Balanced
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:03:23Z.
Review: APPROVED
Reviewed exact head
4fea1089eda184a9916fc5da9b9de4a2a03d03fd. Both CLI paths read inputs before checking existing output aliases withPath.samefile, then reject before HIP work or output writes; this preserves the documented missing-input behavior and avoids treating case-distinct names as aliases on case-sensitive filesystems. The regression tests verify exact-path and hard-link aliases, preserve input bytes, prevent HIP calls, and cover the Windows case-distinct identity edge.I independently ran the exact-head
tools/hw-oracle/test_hw_oracle.pyfrom a temporary archive of this PR: 46 tests passed, 2 platform skips.python3 tools/check_conventions.py --base upstream/main --head upstream/pr/11275andgit diff --check upstream/main...upstream/pr/11275pass. Hosted conventions and labels pass. The Windows Python 3.9/3.12 runs and POSIX symlink probe are author-reported.