rpf_probe: write non-regular --out directly, guard empty/trailing-sep paths, enforce strict JSON (RPF-PROBE-NONREG-AND-OUT-GUARDS) #1593

Merged
IlyassRS3 merged 1 commit from upstream-pr/1593 into main 2026-11-28 10:30:54 +00:00
IlyassRS3 commented 2026-11-25 05:28:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T05:28:15Z.


Item: RPF-PROBE-NONREG-AND-OUT-GUARDS (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/rpf_probe.py).

Summary

  • Fix _write_json_report()'s non-regular destination branch: os.stat("/dev/null") succeeds with a character-device mode rather than raising OSError, so checking not stat.S_ISREG(mode) actually takes the direct-write path for /dev/null and pipes instead of attempting to stage a temp file in /dev and replace /dev/null.
  • Reject empty/whitespace game_dir or --out and trailing-separator --out directory paths before scanning archives (previously --out " " created a whitespace-named file in cwd and --out new_folder/ wrote a regular file named new_folder).
  • Enforce allow_nan=False and a trailing \n on written JSON reports, avoid computing entropy(body) twice per archive in probe(), and accept optional argv=None in main().

Verification

  • python3 -W error -I tests/test_rpf_probe.py -v: 33/33 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/rpf_probe.py tests/test_rpf_probe.py: passed.
  • python3 -m compileall -q tools/rpf_probe.py tests/test_rpf_probe.py: passed.
  • Mutation check (running tests/test_rpf_probe.py against unpatched main:tools/rpf_probe.py): failures=6, errors=0 across all 3 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python archive header survey tool; synthetic headers only, no game data)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485733291 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1593). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T05:28:15Z. --- Item: `RPF-PROBE-NONREG-AND-OUT-GUARDS` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/rpf_probe.py`). ### Summary - Fix `_write_json_report()`'s non-regular destination branch: `os.stat("/dev/null")` succeeds with a character-device mode rather than raising `OSError`, so checking `not stat.S_ISREG(mode)` actually takes the direct-write path for `/dev/null` and pipes instead of attempting to stage a temp file in `/dev` and replace `/dev/null`. - Reject empty/whitespace `game_dir` or `--out` and trailing-separator `--out` directory paths before scanning archives (previously `--out " "` created a whitespace-named file in `cwd` and `--out new_folder/` wrote a regular file named `new_folder`). - Enforce `allow_nan=False` and a trailing `\n` on written JSON reports, avoid computing `entropy(body)` twice per archive in `probe()`, and accept optional `argv=None` in `main()`. ### Verification - `python3 -W error -I tests/test_rpf_probe.py -v`: 33/33 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/rpf_probe.py tests/test_rpf_probe.py`: passed. - `python3 -m compileall -q tools/rpf_probe.py tests/test_rpf_probe.py`: passed. - Mutation check (running `tests/test_rpf_probe.py` against unpatched `main:tools/rpf_probe.py`): `failures=6, errors=0` across all 3 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python archive header survey tool; synthetic headers only, no game data)
copilot-pull-request-reviewer[bot] commented 2026-11-25 05:28:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T05:28:30Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6052299487 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1593#pullrequestreview-6052299487). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T05:28:30Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MoonEyes commented 2026-11-28 10:30:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:30:32Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 18 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237941352 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1593#issuecomment-7237941352). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T10:30:32Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 18 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
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
ProjectLeonida/mandy!1593
No description provided.