Repository navigation
fix(tools): protect sanitizer report inputs from summary writes - #12349
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
One non-blocking edge case to consider: Path.resolve() raises RuntimeError for a symlink loop on Python 3.11 (reproduced with a self-referential summary symlink). This call is inside the new guard, but the existing handler catches OSError, ValueError, and parse errors—not RuntimeError—so --summary <loop> still prints a traceback instead of the CLI’s controlled exit-2 diagnostic. It does not appear to risk overwriting the inputs, but using os.path.realpath() as in the symlink-loop handling in #12340, or translating the exception to ValueError, plus a focused regression would make the error path consistent.
|
I fetched the exact PR head ( |
rooklz
left a comment
There was a problem hiding this comment.
Independent macOS check of exact head 474b9c3eb5 (arm64, macOS; Python 3.9.6 system and 3.13.13 Homebrew).
- Head:
python3 tools/tests/test_sanitizer_report.py→ 25 OK on 3.9.6 and 3.13.13. (My local Homebrew 3.12/3.14 have a brokenpyexpatthat fails every XML case on main too, so those runs are an environment problem and I don't count them.) - Base source (
5ae16ad52bsanitizer_report.pywith the head tests): RED on all 6 new alias subtests (4 FAIL, 2 ERROR);test_separate_summary_still_appendspasses on base, so it works as a control. - Mutants: dropping
args.knownfrom the tuple → killed; droppingargs.junit→ killed; dropping thesamefilearm → killed. Dropping theresolve() == resolve()arm survives, and so does replacing it withsource == args.summary. - Conventions on the head: clean.
git merge-treeagainst current main3a40945e62: clean (main hasn't touched either file since your base).
Non-blocking, about MarcZX10's symlink-loop note: the resolve() arm looks redundant. If both paths exist, samefile already catches every alias that resolve() catches. If the summary doesn't exist, two equal resolved paths mean the input doesn't exist either, and load_known/results already exit 2. That arm is also the only reason the guard can raise RuntimeError (3.9–3.12). I tried the guard with only source.exists() and args.summary.exists() and source.samefile(args.summary): 25 OK on 3.9 and 3.13, all six alias subtests still RED without it. With that change, --summary <loop> behaves exactly as on main.
Separate, pre-existing and out of scope for this PR: on main, --summary pointing at a symlink loop or a directory already gives a traceback with rc 1 on every Python version (OSError ELOOP / IsADirectoryError from args.summary.open("a"), after stdout has already been written). That's because the append happens outside the try. So the loop traceback MarcZX10 reported isn't a regression from this PR; on 3.9–3.12 it just fails earlier with a different exception.
Approving: the guard is correct, the tests fail without it and pass with it, and the note above is optional.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 474b9c3eb555dcd4fdd8d36f7bb422c1e9be5ec8. The validator now rejects malformed manifests before fetching the archive, enforces target/hash-addressed path agreement and size bounds, and the fixtures cover valid downloads, invalid schema, checksum mismatch, incomplete/oversized downloads, and canceled streams. The existing archive tests were updated to use checksum-addressed paths. The exact-head local Node suite passed 25 tests; the independent maintainer reports 25 passing on macOS with Python 3.9 and 3.13, and hosted Ubuntu/Windows relinker, ASan, conventions, intake, and output-directory checks pass.
One low-priority diagnostic edge remains: a self-referential symlink passed as the summary path can make Path.resolve() raise RuntimeError, which is not currently converted to the normal exit-2 diagnostic. That does not undermine the write-protection behavior under review; I’ve left it as a follow-up rather than a merge blocker.
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed 474b9c3eb555dcd4fdd8d36f7bb422c1e9be5ec8 — approve. The sanitizer summary output is checked against both the JUnit input and known-failures file before either can be overwritten, including hardlink aliases.
Windows/Python 3.11: head test_sanitizer_report.py: 23 passed, 2 skipped (25 total); base test_sanitizer_report.py: 21 passed, 0 skipped (21 total). The hardlink CLI preservation cases execute; current tests fail against old production. The regular-file summary behavior stays covered. Symlink-creation skips are recorded separately; this does not execute an instrumented sanitizer build.
What
--summaryappends Markdown and could corrupt its own JUnit or--knowninput when the paths are identical or linked. Reject resolved-path, symlink and existing hardlink aliases before reading, reporting or writing, using the existing exit-2 error path.Implementation basis: The current CLI accepts separate input paths and an append-only summary destination.
Path.resolve()and existing-filesamefile()establish path/file identity without changing the report classifier or known-failure policy.Reference sources at the starting main: tools/sanitizer_report.py.
Tested
Exact PR head:
474b9c3eb555dcd4fdd8d36f7bb422c1e9be5ec8; refreshed starting main:5ae16ad52b5ab6be84c135de0eadb97545616c26. Each branch contains one independent commit.Windows: MinGW GCC 15.2, CMake 4.3.1, Python 3.14.3, Node 24.14.1. WSL Ubuntu 26.04: GCC 15.2, CMake 4.2.3, Python 3.14.4, Node 22.22.1. Native builds use Ninja Release,
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ONandcmake --build BUILD --parallel 8. Focused CTest runs use-V --parallel 4on Windows and-V --parallel 8on WSL; test-registration and skip-policy audits pass.Command:
ctest --test-dir BUILD -R '^sanitizer_report$' -V --parallel N.Direct, relative, hardlink and symlink aliases for both inputs preserve bytes and produce no stdout; a distinct destination still appends successfully. The old production implementation fails the direct-alias regression. Both platform skip policies and test registration audits passed.
Current-main integration: checked each branch's independent three-way merge against
3a40945e62b7e2543031d5da2b8e351ab603bc1a(all clean), then built and tested the actual merge of that main and all ten exact heads at91a099a5c398b221b4a88a8f0e0f0b1068a2dbb9. On each OS, all 86 selected CTest groups and 30 Node tests passed. Slowest CTest group: 9.77s Windows / 4.26s WSL. This combined run supplements the independent head runs; it does not make another project a prerequisite. Main's newly merged release-note/cache/test-runner changes were preserved. No locally exercised final CTest group exceeded 30s.Additional shared-source compatibility checks passed on both OSes at these exact snapshots. These are selected production/test file projections onto the local combination, not whole external PR builds:
f25c397e16b8f4ef891f778d021deb373ad8d6cd9d56116f5a99664fb378f750bc1e1cb530ec69ac792c8791f0fb1487b64ce519788df5d0afde1f8368f5be7de646ab4a3bab4d84d789858c5750cef4A final open-PR refresh examined 68 new/updated heads since screening. The only newly shared files belonged to #12338 (release-note symlink-loop diagnostics,
761fe2785b28082fda8ce5910cb0e7e4451329bf) and #12328 (separate fuzz-seed test registration,70993dbf30e355257458a9028785ac5a131fe033). Both merge cleanly with the tested current-main combination at9ca88c064583c44d0707810d2ec2873f2608489d. In that context the release-note suite and registration audits passed on both OSes, with all 70 trace cases and both CSV registrations preserved. These are focused integration checks, not whole external PR builds. Their behavior is distinct and introduces no ordering dependency.Pre-push review:
git diff --check, Python 3.9 grammar parsing of changed Python files, current-main conventions checker with this complete body, and production test registration audit. Officialtools/pr_overlap.py --branch BRANCH --jobs 2completed against all open PRs at its recorded snapshot. Its result wasNo overlap with open pull requests.No same behavior was identified in the open-PR/history review; no ordering dependency is required in this snapshot.Known limits: This is an input-preservation guard, not a race-proof filesystem transaction. Windows symlink cases require privileges and were skipped; Linux executed them. No sanitizer-instrumented product run is claimed. macOS and an older Python runtime were not available locally; Python 3.9 syntax parsing is not runtime testing. No full system-library build, PS5 measurement or game run is claimed. Hosted checks are pending publication/maintainer workflow dispatch and are not counted as local passes.
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)