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

Open
github-bot wants to merge 1 commit from github-bot/gh-1603 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 05:37 UTC · original
IlyassRS3:fix/tex-export-guards-and-atomic-log → main · +195 −11 · 2 files · 1 commits · open

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)

**@⁠IlyassRS3** on GitHub · 2026-11-25 05:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1603) `IlyassRS3:fix/tex-export-guards-and-atomic-log` → `main` · +195 −11 · 2 files · 1 commits · open 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:48 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 05:37 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 05:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1603#pullrequestreview-6052383985) · **reviewed** 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.
Author
Owner

@⁠ZroIsHere on GitHub · 2026-11-26 01:10 UTC · original

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

**@⁠ZroIsHere** on GitHub · 2026-11-26 01:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1603#issuecomment-7179507386) I opened a stacked draft follow-up for symlink containment in carve reads and texture/report writes: https://github.com/IlyassRS3/leonida/pull/3
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1603/head:github-bot/gh-1603'
git switch 'github-bot/gh-1603'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1603'
git switch 'github-bot/gh-1603'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1603'
git switch 'github-bot/gh-1603'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1603'
git switch 'main'
git merge --squash 'github-bot/gh-1603'
git switch 'main'
git merge --ff-only 'github-bot/gh-1603'
git switch 'main'
git merge 'github-bot/gh-1603'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.