fix(progress): refuse aliased reports via realpath targets #13171

Merged
rooklz merged 1 commit from upstream-pr/13171 into main 2026-11-02 17:27:41 +00:00
rooklz commented 2026-10-30 05:11:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-30T05:11:03Z.


What

Merged #12301 added require_distinct_reports using exists() + samefile(), but two alias shapes still slip through:

  1. Dangling symlinks to one missing target — exists() is false for both, so the pair is skipped; write_site then creates one file and the JSON report is lost (#12055 via symlink).
  2. Adjacent hardlinked pair with other reports absent — the existing test only hardlinks non-adjacent progress.json / progress.html while all five site files exist, so mutants that drop the index + 1 slice or skip the exists check still pass.

After the samefile loop, compare os.path.normcase(os.path.realpath(...)) for every report path (same idea as progress_history.same_location). Two new tests cover the missing-target symlink pair and an adjacent badge hardlink with no other outputs present.

Tested

macOS (Apple M5), relinker-only Release, BUILD_TESTING=ON, -DPython3_EXECUTABLE=/opt/homebrew/bin/python3.13, base 5ecef095b6 (branch @401f8138f0):

  • Base progress.py, head tests: test_reports_linked_to_one_missing_target_are_refused FAIL (rc 0).
  • Head: python3.13 -m unittest discover -s tools/tests -p test_progress.py → 58 OK; /usr/bin/python3 (3.9.6) → new tests OK.
  • check_conventions.py --base upstream/main PASS; pr_overlap.py --branch fix/progress-realpath-aliases → no overlap (1453 PRs).
  • ctest build-relinker: 510/510 (progress_report included; iter426 rebase verify).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5079796176 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13171). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-30T05:11:03Z. --- ### What Merged #12301 added `require_distinct_reports` using `exists()` + `samefile()`, but two alias shapes still slip through: 1. **Dangling symlinks to one missing target** — `exists()` is false for both, so the pair is skipped; `write_site` then creates one file and the JSON report is lost (#12055 via symlink). 2. **Adjacent hardlinked pair with other reports absent** — the existing test only hardlinks non-adjacent `progress.json` / `progress.html` while all five site files exist, so mutants that drop the `index + 1` slice or skip the exists check still pass. After the samefile loop, compare `os.path.normcase(os.path.realpath(...))` for every report path (same idea as `progress_history.same_location`). Two new tests cover the missing-target symlink pair and an adjacent badge hardlink with no other outputs present. ### Tested macOS (Apple M5), relinker-only Release, `BUILD_TESTING=ON`, `-DPython3_EXECUTABLE=/opt/homebrew/bin/python3.13`, base `5ecef095b6` (branch @401f8138f0): - Base `progress.py`, head tests: `test_reports_linked_to_one_missing_target_are_refused` FAIL (rc 0). - Head: `python3.13 -m unittest discover -s tools/tests -p test_progress.py` → 58 OK; `/usr/bin/python3` (3.9.6) → new tests OK. - `check_conventions.py --base upstream/main` PASS; `pr_overlap.py --branch fix/progress-realpath-aliases` → no overlap (1453 PRs). - ctest `build-relinker`: **510/510** (progress_report included; iter426 rebase verify). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-30 05:17:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T05:17:06Z.

Review: APPROVED


Reviewed — looks good

The new path comparison rejects dangling symlinks to a shared target, and the adjacent hardlink case is now covered with other outputs absent.

What I ran

Reviewed exact head 609e1685221a140311461b31f27fb021265f9085 against current main 8c8b9986204d5b1cbb23847b363df00ae832ec9c; the merge preview is clean (7b4f0daf7cb62193f527c446ed87efd255b1c8b3). Environment: Linux x86-64, Python 3.11.2; no compiler or build invoked.

git merge-tree --write-tree 8c8b9986204d5b1cbb23847b363df00ae832ec9c 609e1685221a140311461b31f27fb021265f9085
git diff --check 8c8b9986204d5b1cbb23847b363df00ae832ec9c...609e1685221a140311461b31f27fb021265f9085
python3 tools/check_conventions.py --base upstream/main --head refs/remotes/upstream/pr-13171-current
cd /tmp/AnyPS5-review-13171-pr
python3 -m unittest tools.tests.test_progress
cp /tmp/AnyPS5-review-13171-pr/tools/tests/test_progress.py /tmp/AnyPS5-review-13171-main/tools/tests/test_progress.py
cd /tmp/AnyPS5-review-13171-main
python3 -m unittest tools.tests.test_progress.ProgressTests.test_reports_linked_to_one_missing_target_are_refused

The last command is the negative control: the PR's test file ran with current main's implementation.

Results

Check Result
Merge preview with current main Clean; tree 7b4f0daf7cb62193f527c446ed87efd255b1c8b3
Diff check Passed; no whitespace errors
Conventions Passed
tools.tests.test_progress on PR head Passed; 58 tests
Negative control with current main implementation Failed as expected: the dangling-symlink test did not raise SystemExit
Hosted checks Ubuntu relinker, relinker ASan, conventions, intake, labels, eligibility, and report passed. Windows and macOS relinker jobs were pending at review time; product and specialized jobs were skipped.
Local command output
git merge-tree --write-tree 8c8b9986204d5b1cbb23847b363df00ae832ec9c 609e1685221a140311461b31f27fb021265f9085
7b4f0daf7cb62193f527c446ed87efd255b1c8b3

git diff --check 8c8b9986204d5b1cbb23847b363df00ae832ec9c...609e1685221a140311461b31f27fb021265f9085
(no output; exit status 0)

python3 tools/check_conventions.py --base upstream/main --head refs/remotes/upstream/pr-13171-current
All conventions checks passed.

python3 -m unittest tools.tests.test_progress
..........................................................
----------------------------------------------------------------------
Ran 58 tests in 0.342s

OK

python3 -m unittest tools.tests.test_progress.ProgressTests.test_reports_linked_to_one_missing_target_are_refused
F
======================================================================
FAIL: test_reports_linked_to_one_missing_target_are_refused (tools.tests.test_progress.ProgressTests.test_reports_linked_to_one_missing_target_are_refused)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/AnyPS5-review-13171-main/tools/tests/test_progress.py", line 830, in test_reports_linked_to_one_missing_target_are_refused
    with patch("sys.stderr", stderr), self.assertRaises(SystemExit) as raised:
AssertionError: SystemExit not raised
----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (failures=1)

Negative control

Assertion Change to code under test Did the new test fail?
Two report symlinks to one missing target are rejected before output is written. Ran the PR's test file against current main's tools/progress.py. Yes; SystemExit was not raised.

Findings

Blocking

None found.

Non-blocking

The author reports macOS Python 3.13 and 3.9 runs and a 510/510 relinker-only CTest result. I did not reproduce those runs. Windows and macOS hosted relinker jobs were still pending when I checked.

Sources

Not verified

No Windows or macOS Python run, local build, or full project test suite was run. The hosted Windows/macOS relinker jobs were pending; product and specialized jobs were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5708360536 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13171#pullrequestreview-5708360536). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T05:17:06Z. **Review:** APPROVED --- # Reviewed — looks good The new path comparison rejects dangling symlinks to a shared target, and the adjacent hardlink case is now covered with other outputs absent. ## What I ran Reviewed exact head `609e1685221a140311461b31f27fb021265f9085` against current `main` `8c8b9986204d5b1cbb23847b363df00ae832ec9c`; the merge preview is clean (`7b4f0daf7cb62193f527c446ed87efd255b1c8b3`). Environment: Linux x86-64, Python 3.11.2; no compiler or build invoked. ```sh git merge-tree --write-tree 8c8b9986204d5b1cbb23847b363df00ae832ec9c 609e1685221a140311461b31f27fb021265f9085 git diff --check 8c8b9986204d5b1cbb23847b363df00ae832ec9c...609e1685221a140311461b31f27fb021265f9085 python3 tools/check_conventions.py --base upstream/main --head refs/remotes/upstream/pr-13171-current cd /tmp/AnyPS5-review-13171-pr python3 -m unittest tools.tests.test_progress cp /tmp/AnyPS5-review-13171-pr/tools/tests/test_progress.py /tmp/AnyPS5-review-13171-main/tools/tests/test_progress.py cd /tmp/AnyPS5-review-13171-main python3 -m unittest tools.tests.test_progress.ProgressTests.test_reports_linked_to_one_missing_target_are_refused ``` The last command is the negative control: the PR's test file ran with current `main`'s implementation. ## Results | Check | Result | |---|---| | Merge preview with current `main` | Clean; tree `7b4f0daf7cb62193f527c446ed87efd255b1c8b3` | | Diff check | Passed; no whitespace errors | | Conventions | Passed | | `tools.tests.test_progress` on PR head | Passed; 58 tests | | Negative control with current `main` implementation | Failed as expected: the dangling-symlink test did not raise `SystemExit` | | Hosted checks | Ubuntu relinker, relinker ASan, conventions, intake, labels, eligibility, and report passed. Windows and macOS relinker jobs were pending at review time; product and specialized jobs were skipped. | <details> <summary>Local command output</summary> ```text git merge-tree --write-tree 8c8b9986204d5b1cbb23847b363df00ae832ec9c 609e1685221a140311461b31f27fb021265f9085 7b4f0daf7cb62193f527c446ed87efd255b1c8b3 git diff --check 8c8b9986204d5b1cbb23847b363df00ae832ec9c...609e1685221a140311461b31f27fb021265f9085 (no output; exit status 0) python3 tools/check_conventions.py --base upstream/main --head refs/remotes/upstream/pr-13171-current All conventions checks passed. python3 -m unittest tools.tests.test_progress .......................................................... ---------------------------------------------------------------------- Ran 58 tests in 0.342s OK python3 -m unittest tools.tests.test_progress.ProgressTests.test_reports_linked_to_one_missing_target_are_refused F ====================================================================== FAIL: test_reports_linked_to_one_missing_target_are_refused (tools.tests.test_progress.ProgressTests.test_reports_linked_to_one_missing_target_are_refused) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/AnyPS5-review-13171-main/tools/tests/test_progress.py", line 830, in test_reports_linked_to_one_missing_target_are_refused with patch("sys.stderr", stderr), self.assertRaises(SystemExit) as raised: AssertionError: SystemExit not raised ---------------------------------------------------------------------- Ran 1 test in 0.003s FAILED (failures=1) ``` </details> ## Negative control | Assertion | Change to code under test | Did the new test fail? | |---|---|---| | Two report symlinks to one missing target are rejected before output is written. | Ran the PR's test file against current `main`'s `tools/progress.py`. | Yes; `SystemExit` was not raised. | ## Findings ### Blocking None found. ### Non-blocking The author reports macOS Python 3.13 and 3.9 runs and a 510/510 relinker-only CTest result. I did not reproduce those runs. Windows and macOS hosted relinker jobs were still pending when I checked. ## Sources - [Alias-path check at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/609e1685221a140311461b31f27fb021265f9085/tools/progress.py#L520-L530) - [New alias regression tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/609e1685221a140311461b31f27fb021265f9085/tools/tests/test_progress.py#L800-L834) ## Not verified No Windows or macOS Python run, local build, or full project test suite was run. The hosted Windows/macOS relinker jobs were pending; product and specialized jobs were skipped.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!13171
No description provided.