tex_export: validate dimensions and paths, clean partial DDS, write export_log atomically (TEX-EXPORT-GUARDS-AND-ATOMIC-LOG) #1603

Merged
leonida/mandy
quietfold merged 1 commit from fix/tex-export-guards-and-atomic-log into main 2026-11-28 10:34:50 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 05:37:38 +00:00

Item: TEX-EXPORT-GUARDS-AND-ATOMIC-LOG (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/tex_export.py).

Summary

  • Validate positive non-bool integer dimensions in detile_offsets() and export_one(), and reject empty, absolute, or ..-traversing archive paths and path-separator fmt_name values before opening blobs or creating output subdirectories.
  • Remove partially written .dds files if write() fails with OSError in export_one(), matching the existing PNG partial-file cleanup.
  • Reject empty or whitespace-only index/carve/out arguments in main(argv=None) (preventing " " directory creation in cwd), and catch RecursionError when loading textures_index.json.
  • Publish export_log.json atomically via file_mode.published_mode + replace_retry.replace with allow_nan=False (preserving existing logs on write failure and handling non-regular targets), keeping the exact compact JSON format.

Verification

  • python3 -W error -m pytest tests/test_tex_export.py -q: 144 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/tex_export.py tests/test_tex_export.py: passed.
  • python3 -m compileall -q tools/tex_export.py tests/test_tex_export.py: passed.
  • Mutation check (running tests/test_tex_export.py against unpatched main:tools/tex_export.py): 10 failed, 134 passed across all new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python texture exporter; synthetic swizzle equations and blobs only, no game data)

Item: `TEX-EXPORT-GUARDS-AND-ATOMIC-LOG` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/tex_export.py`). ### Summary - Validate positive non-bool integer dimensions in `detile_offsets()` and `export_one()`, and reject empty, absolute, or `..`-traversing `archive` paths and path-separator `fmt_name` values before opening blobs or creating output subdirectories. - Remove partially written `.dds` files if `write()` fails with `OSError` in `export_one()`, matching the existing PNG partial-file cleanup. - Reject empty or whitespace-only `index`/`carve`/`out` arguments in `main(argv=None)` (preventing `" "` directory creation in `cwd`), and catch `RecursionError` when loading `textures_index.json`. - Publish `export_log.json` atomically via `file_mode.published_mode` + `replace_retry.replace` with `allow_nan=False` (preserving existing logs on write failure and handling non-regular targets), keeping the exact compact JSON format. ### Verification - `python3 -W error -m pytest tests/test_tex_export.py -q`: 144 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/tex_export.py tests/test_tex_export.py`: passed. - `python3 -m compileall -q tools/tex_export.py tests/test_tex_export.py`: passed. - Mutation check (running `tests/test_tex_export.py` against unpatched `main:tools/tex_export.py`): 10 failed, 134 passed across all new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python texture exporter; synthetic swizzle equations and blobs only, no game data)
copilot-pull-request-reviewer[bot] reviewed 2026-11-25 05:37:52 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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.
ZroIsHere commented 2026-11-26 01:10:29 +00:00

I opened a stacked draft follow-up for symlink containment in carve reads and texture/report writes: https://github.com/IlyassRS3/leonida/pull/3

I opened a stacked draft follow-up for symlink containment in carve reads and texture/report writes: https://github.com/IlyassRS3/leonida/pull/3
MoonEyes commented 2026-11-28 10:34:38 +00:00

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)

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 description provided.