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

Open
opened 2026-11-26 20:21:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1593
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/rpf-probe-nonreg-and-out-guards


📝 Commits (1)

  • c5a4efe rpf_probe: write non-regular --out directly, guard empty/trailing-sep paths, enforce strict JSON

📊 Changes

2 files changed (+61 additions, -8 deletions)

View changed files

📝 tests/test_rpf_probe.py (+41 -0)
📝 tools/rpf_probe.py (+20 -8)

📄 Description

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)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1593 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/rpf-probe-nonreg-and-out-guards` --- ### 📝 Commits (1) - [`c5a4efe`](https://github.com/ubiquitarianism/leonida/commit/c5a4efea04f2a525422ae71df3cdaea5efa50989) rpf_probe: write non-regular --out directly, guard empty/trailing-sep paths, enforce strict JSON ### 📊 Changes **2 files changed** (+61 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_rpf_probe.py` (+41 -0) 📝 `tools/rpf_probe.py` (+20 -8) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1612
No description provided.