shader_library: reject --save paths that overlap extraction outputs #465

Merged
EdenBendheim merged 1 commit from upstream-pr/465 into main 2026-11-24 08:53:30 +00:00
EdenBendheim commented 2026-11-24 05:50:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-11-24T05:50:02Z.


Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7123317138

What changed

  • tools/shader_library.py: Validate --save with same_report_path against all requested --out outputs (index.json, library.json, selected fspx/ .code/.json/.state including stale-state cleanup paths, matched .dxbc, eligible disasm/ .s, output directories, and ancestors of --out) before creating directories or writing either output. Overlapping paths exit 2 leaving existing files untouched; non-overlapping --save inside a fresh --out tree succeeds because extraction directories are created before opening --save.
  • tests/test_shader_library.py: Synthetic tests covering fresh/existing outputs, path aliases (relative, case-only, symlink, hardlink), ancestor-directory collisions, nested fresh-tree saves, and separate destinations.

Testing & Disclosure

  • AI-assisted: Implemented with Codex (gpt-6.2-sol) and reviewed with Codex (gpt-6.2-astra).
  • Environment: macOS 27.3, Apple M1 Max, Python 3.14.3 (CPU-only, synthetic fixtures, zero game data).
  • Verified on ubiquitarianism/leonida main (8f481cf16): all test_shader_library*.py and test_*report_paths.py suites (76/76), compileall, check_no_game_data.py, LF check — all passed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5466874761 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/465). Originally posted by [EdenBendheim](https://github.com/EdenBendheim) on 2026-11-24T05:50:02Z. --- Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7123317138 ### What changed - **`tools/shader_library.py`**: Validate `--save` with `same_report_path` against all requested `--out` outputs (`index.json`, `library.json`, selected `fspx/` `.code`/`.json`/`.state` including stale-state cleanup paths, matched `.dxbc`, eligible `disasm/` `.s`, output directories, and ancestors of `--out`) before creating directories or writing either output. Overlapping paths exit `2` leaving existing files untouched; non-overlapping `--save` inside a fresh `--out` tree succeeds because extraction directories are created before opening `--save`. - **`tests/test_shader_library.py`**: Synthetic tests covering fresh/existing outputs, path aliases (relative, case-only, symlink, hardlink), ancestor-directory collisions, nested fresh-tree saves, and separate destinations. ### Testing & Disclosure - **AI-assisted:** Implemented with Codex (`gpt-6.2-sol`) and reviewed with Codex (`gpt-6.2-astra`). - **Environment:** macOS 27.3, Apple M1 Max, Python 3.14.3 (CPU-only, synthetic fixtures, zero game data). - **Verified on `ubiquitarianism/leonida` `main` (`8f481cf16`):** all `test_shader_library*.py` and `test_*report_paths.py` suites (76/76), `compileall`, `check_no_game_data.py`, LF check — all passed.
QemmHD commented 2026-11-24 08:53:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T08:53:28Z.


Merging. Why merged: a --save path that would overwrite extraction outputs is refused before anything is written.
Why it's good: security-reviewed; on main 1c93c86: shader_library tests 31 -> 37 (19 fail without the fix); it uses report_paths, which is already a listed translator input; repo-consistency set 563/563.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7126691264 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/465#issuecomment-7126691264). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T08:53:28Z. --- Merging. Why merged: a --save path that would overwrite extraction outputs is refused before anything is written. Why it's good: security-reviewed; on main 1c93c86: shader_library tests 31 -> 37 (19 fail without the fix); it uses report_paths, which is already a listed translator input; repo-consistency set 563/563. 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!465
No description provided.