textures: validate archive inputs and lookup keys upfront in texture_descriptors CLI #2657

Merged
Ammmae0x merged 1 commit from upstream-pr/2665 into main 2026-11-26 02:48:57 +00:00
Ammmae0x commented 2026-11-26 01:32:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-26T01:32:59Z.


Change

Validate archive paths and --lookup-key bounds upfront in tools/texture_descriptors.py before opening any file, and add a pure-Python synthetic RDS5/ETPF CLI test suite (tests/texture_descriptors_cli_check.py) registered in CMakeLists.txt as textures_texture_descriptors_cli_check (TIMEOUT 60).

  • Check len(args.archives) != 1 when --lookup-key is omitted immediately after parse_args.
  • Validate 0 <= key < (1 << 64) upfront in --lookup-key mode before opening archives.
  • Verify every archive path exists and is_file() upfront before opening any archive, preserving the {archive}: {exc} stderr format and exit code 1 with zero tracebacks.

Verification

  • Commit: 47f5e5a1 (based on upstream/main 31bcd9ad)
  • out\pe-env\Scripts\python.exe -B tests\texture_descriptors_cli_check.py -> Ran 7 tests in 2.460s / OK (exit 0)
  • out\pe-env\Scripts\python.exe -B tests\texture_descriptors_check.py -> texture_descriptors: synthetic RDS5/ETPF helpers, JSON CLI modes, and error exits passed (exit 0)
  • out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py -> form coverage checks passed (exit 0)
  • out\pe-env\Scripts\python.exe -B tests\docs_links_check.py -> Self-test passed. Checked 19 Markdown files and 510 links. (exit 0)
  • out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py -> Self-test passed. Checked 1893 tracked source, script and build/CI files: no bidirectional controls. (exit 0)
  • Spot-mutation gate: 3/3 mutations killed (upfront --lookup-key range check, candidate.exists(), candidate.is_file()).
  • Negative controls: missing/directory archives (single and multi-archive --lookup-key with mocked Path.open verifying zero opens), negative and >= 2^64 keys, negative descriptor indices, truncated headers, corrupt zlib stream, duplicate/hardlink archives, and Python 3.14-safe argparse error exits.

Evidence and follow-up

All fixtures in tests/texture_descriptors_cli_check.py are synthetic in-memory RDS5/ETPF byte buffers constructed by Python helper functions under the repository MIT license; no external or game files are used. Existing tools/texture_descriptors.py JSON output shapes and tests/texture_descriptors_check.py remain unchanged.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6617472629 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2665). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-26T01:32:59Z. --- ## Change Validate archive paths and `--lookup-key` bounds upfront in `tools/texture_descriptors.py` before opening any file, and add a pure-Python synthetic RDS5/ETPF CLI test suite (`tests/texture_descriptors_cli_check.py`) registered in `CMakeLists.txt` as `textures_texture_descriptors_cli_check` (`TIMEOUT 60`). - Check `len(args.archives) != 1` when `--lookup-key` is omitted immediately after `parse_args`. - Validate `0 <= key < (1 << 64)` upfront in `--lookup-key` mode before opening archives. - Verify every archive path exists and `is_file()` upfront before opening any archive, preserving the `{archive}: {exc}` stderr format and exit code `1` with zero tracebacks. ## Verification - Commit: `47f5e5a1` (based on `upstream/main` `31bcd9ad`) - `out\pe-env\Scripts\python.exe -B tests\texture_descriptors_cli_check.py` -> `Ran 7 tests in 2.460s / OK` (exit 0) - `out\pe-env\Scripts\python.exe -B tests\texture_descriptors_check.py` -> `texture_descriptors: synthetic RDS5/ETPF helpers, JSON CLI modes, and error exits passed` (exit 0) - `out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py` -> `form coverage checks passed` (exit 0) - `out\pe-env\Scripts\python.exe -B tests\docs_links_check.py` -> `Self-test passed. Checked 19 Markdown files and 510 links.` (exit 0) - `out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py` -> `Self-test passed. Checked 1893 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) - Spot-mutation gate: 3/3 mutations killed (upfront `--lookup-key` range check, `candidate.exists()`, `candidate.is_file()`). - Negative controls: missing/directory archives (single and multi-archive `--lookup-key` with mocked `Path.open` verifying zero opens), negative and `>= 2^64` keys, negative descriptor indices, truncated headers, corrupt zlib stream, duplicate/hardlink archives, and Python 3.14-safe argparse error exits. ## Evidence and follow-up All fixtures in `tests/texture_descriptors_cli_check.py` are synthetic in-memory RDS5/ETPF byte buffers constructed by Python helper functions under the repository MIT license; no external or game files are used. Existing `tools/texture_descriptors.py` JSON output shapes and `tests/texture_descriptors_check.py` remain unchanged. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
tedin7 commented 2026-11-26 02:05:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:37:37Z.

Review: COMMENTED


Review of head 47f5e5a1 against origin/main. No blocking findings.

  • tools/texture_descriptors.py: the "multiple archives need --lookup-key" check now runs before anything else. Lookup keys are range-checked as unsigned 64-bit. Every archive is checked (exists, regular file) before any parsing starts. Behavior for valid input is unchanged.
  • The new suite tests/texture_descriptors_cli_check.py (7 tests) is registered in CMake as textures_texture_descriptors_cli_check, next to the sibling texture_descriptors_check.
  • No other open PR covers this slice. #2334 (merged) touched the same tool earlier.

Commands run in a worktree on this head:

  • python3 -B tests/texture_descriptors_cli_check.py -> 7 tests OK
  • python3 -B tests/texture_descriptors_check.py -> OK
  • python3 tests/docs_links_check.py -> OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • Mutation: disabling the 64-bit key range check -> 3 errors
  • Mutation: disabling the regular-file check -> 2 errors

Python-only change. A Windows receipt is still pending on my side.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067391495 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2665#pullrequestreview-6067391495). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T01:37:37Z. **Review:** COMMENTED --- Review of head 47f5e5a1 against origin/main. No blocking findings. - `tools/texture_descriptors.py`: the "multiple archives need --lookup-key" check now runs before anything else. Lookup keys are range-checked as unsigned 64-bit. Every archive is checked (exists, regular file) before any parsing starts. Behavior for valid input is unchanged. - The new suite `tests/texture_descriptors_cli_check.py` (7 tests) is registered in CMake as `textures_texture_descriptors_cli_check`, next to the sibling `texture_descriptors_check`. - No other open PR covers this slice. #2334 (merged) touched the same tool earlier. Commands run in a worktree on this head: - `python3 -B tests/texture_descriptors_cli_check.py` -> 7 tests OK - `python3 -B tests/texture_descriptors_check.py` -> OK - `python3 tests/docs_links_check.py` -> OK - `python3 tests/bidi_controls_check.py` -> OK - `git diff --check origin/main...HEAD` -> clean - Mutation: disabling the 64-bit key range check -> 3 errors - Mutation: disabling the regular-file check -> 2 errors Python-only change. A Windows receipt is still pending on my side. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 03:03:05 +00:00
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
R0Y00/Xbox2Windows!2657
No description provided.