fix(tools): handle unwritable summary destinations and reject aliased inputs in sanitizer_report #12433

Closed
opened 2026-10-28 13:30:19 +00:00 by pushkarreddyy · 0 comments
pushkarreddyy commented 2026-10-28 13:30:19 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-28T13:30:19Z.


Problem

tools/sanitizer_report.py has two file-handling defects:

  1. Unhandled Traceback on Unwritable --summary: main() performs input report parsing inside a try ... except (OSError, ET.ParseError, ValueError) block, but writes --summary outside exception handling at lines 130–132 (with args.summary.open("a", encoding="utf-8") as summary:). When --summary points to a nonexistent directory, a directory path, or an unwritable path, it crashes with an unhandled FileNotFoundError, IsADirectoryError, or PermissionError traceback (exit 1) instead of exiting cleanly with return code 2 via sanitizer_report: <error>.
  2. Input File Corruption via Output Alias: --summary is appended to without checking for aliases against the input junit report XML or --known failures list. An aliased summary corrupts the input XML document with appended markdown.

Solution

  • Add preflight alias check rejecting --summary if it targets args.junit or args.known.
  • Wrap --summary writing inside the existing try ... except block so write failures output sanitizer_report: <error> and return 2.
  • Add regression tests in tools/tests/test_sanitizer_report.py.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6079934014 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/12433). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-28T13:30:19Z. --- ### Problem `tools/sanitizer_report.py` has two file-handling defects: 1. **Unhandled Traceback on Unwritable `--summary`**: `main()` performs input report parsing inside a `try ... except (OSError, ET.ParseError, ValueError)` block, but writes `--summary` outside exception handling at lines 130–132 (`with args.summary.open("a", encoding="utf-8") as summary:`). When `--summary` points to a nonexistent directory, a directory path, or an unwritable path, it crashes with an unhandled `FileNotFoundError`, `IsADirectoryError`, or `PermissionError` traceback (exit 1) instead of exiting cleanly with return code 2 via `sanitizer_report: <error>`. 2. **Input File Corruption via Output Alias**: `--summary` is appended to without checking for aliases against the input `junit` report XML or `--known` failures list. An aliased summary corrupts the input XML document with appended markdown. ### Solution - Add preflight alias check rejecting `--summary` if it targets `args.junit` or `args.known`. - Wrap `--summary` writing inside the existing `try ... except` block so write failures output `sanitizer_report: <error>` and return 2. - Add regression tests in `tools/tests/test_sanitizer_report.py`.
Sign in to join this conversation.
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#12433
No description provided.