shader: harden input file and struct/zlib error guards in section_probe with CLI suite #2589

Merged
Ammmae0x merged 2 commits from upstream-pr/2597 into main 2026-11-25 22:36:57 +00:00
Ammmae0x commented 2026-11-25 22:27:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T22:27:53Z.


Summary

  • Validate archive paths in tools/section_probe.py:inspect() via path.is_file() before calling stat()/open(), raising clear ValueError for directories or non-regular files and FileNotFoundError for missing files.
  • Annotate main(argv=None) -> int and wrap [inspect(p, args.first, args.last) for p in args.archives] in except (OSError, ValueError, struct.error, zlib.error) exiting cleanly via parser.exit(1, f"section_probe: {exc}\n") with zero raw tracebacks while preserving exact JSON output schema and --first/--last exit code 2 validation.
  • Add standalone CLI/error/window-dedup/mutation test suite tests/section_probe_cli_check.py and register shader_section_probe_cli_check in CMakeLists.txt.

Verification

  • python -B tests/section_probe_cli_check.py -v -> Ran 6 tests in 0.812s (OK, exit 0)
  • python -B tests/resource_ranges_check.py -> Ran 21 tests in 0.451s (OK, exit 0)
  • Adversarial temp-copy mutation check (15 mutations across is_file/is_dir/exists/non-regular guards, OSError/ValueError/struct.error/zlib.error handlers, exit code, stderr prefix, window overlap dedup, preset-dict skip, argv forwarding, main() return type, and __main__ exit propagation) -> 15/15 KILLED
  • python -B tests/form_coverage_check.py -> form coverage checks passed (exit 0)
  • python -B tests/docs_links_check.py -> Self-test passed. Checked 19 Markdown files and 498 links. (exit 0)
  • python -B tests/bidi_controls_check.py -> Self-test passed. Checked 1824 tracked source, script and build/CI files: no bidirectional controls. (exit 0)

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6615041974 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2597). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T22:27:53Z. --- ## Summary - Validate archive paths in `tools/section_probe.py:inspect()` via `path.is_file()` before calling `stat()`/`open()`, raising clear `ValueError` for directories or non-regular files and `FileNotFoundError` for missing files. - Annotate `main(argv=None) -> int` and wrap `[inspect(p, args.first, args.last) for p in args.archives]` in `except (OSError, ValueError, struct.error, zlib.error)` exiting cleanly via `parser.exit(1, f"section_probe: {exc}\n")` with zero raw tracebacks while preserving exact JSON output schema and `--first`/`--last` exit code 2 validation. - Add standalone CLI/error/window-dedup/mutation test suite `tests/section_probe_cli_check.py` and register `shader_section_probe_cli_check` in `CMakeLists.txt`. ## Verification - `python -B tests/section_probe_cli_check.py -v` -> `Ran 6 tests in 0.812s` (`OK`, exit 0) - `python -B tests/resource_ranges_check.py` -> `Ran 21 tests in 0.451s` (`OK`, exit 0) - Adversarial temp-copy mutation check (15 mutations across `is_file`/`is_dir`/`exists`/non-regular guards, `OSError`/`ValueError`/`struct.error`/`zlib.error` handlers, exit code, stderr prefix, window overlap dedup, preset-dict skip, `argv` forwarding, `main()` return type, and `__main__` exit propagation) -> `15/15 KILLED` - `python -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0) - `python -B tests/docs_links_check.py` -> `Self-test passed. Checked 19 Markdown files and 498 links.` (exit 0) - `python -B tests/bidi_controls_check.py` -> `Self-test passed. Checked 1824 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) AI-assisted.
upstream-sync closed this pull request 2026-11-25 23:01:59 +00:00
tedin7 commented 2026-11-25 23:02:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:31:24Z.

Review: COMMENTED


Review of head 5a937dcb (comment only).

What I checked:

  • tools/section_probe.py: inspect() now rejects missing paths, directories and non-regular files with a clear message. main() turns OSError/ValueError/struct.error/zlib.error into a one-line stderr message and exit code 1 instead of a traceback. Small and correct.
  • CMakeLists.txt: new shader_section_probe_cli_check sits next to the sibling Python checks, same -B pattern.
  • Not a duplicate: only #647 (merged) touches section_probe, and it covers --first/--last tag validation, not these guards.

Commands run (Linux, exact head):

  • python3 -B tests/section_probe_cli_check.py -> 6 tests OK
  • python3 tests/docs_links_check.py -> OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: drop struct.error, zlib.error from the except tuple -> suite FAILS (2 errors)
  • Mutation 2: disable the is_file() guard -> suite FAILS (1 error)

No blocking findings. Win2025 receipt to follow before any merge.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065892305 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2597#pullrequestreview-6065892305). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T22:31:24Z. **Review:** COMMENTED --- Review of head 5a937dcb (comment only). What I checked: - `tools/section_probe.py`: `inspect()` now rejects missing paths, directories and non-regular files with a clear message. `main()` turns OSError/ValueError/struct.error/zlib.error into a one-line stderr message and exit code 1 instead of a traceback. Small and correct. - `CMakeLists.txt`: new `shader_section_probe_cli_check` sits next to the sibling Python checks, same `-B` pattern. - Not a duplicate: only #647 (merged) touches section_probe, and it covers `--first/--last` tag validation, not these guards. Commands run (Linux, exact head): - `python3 -B tests/section_probe_cli_check.py` -> 6 tests OK - `python3 tests/docs_links_check.py` -> OK - `python3 tests/bidi_controls_check.py` -> OK - `git diff --check origin/main...HEAD` -> clean - Mutation 1: drop `struct.error, zlib.error` from the except tuple -> suite FAILS (2 errors) - Mutation 2: disable the `is_file()` guard -> suite FAILS (1 error) No blocking findings. Win2025 receipt to follow before any merge. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 23:02:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:36:45Z.


Win2025 WARP receipt for head a16feab8 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit a16feab8b75030a9547ea140143fddb7023742d9:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 31.26s (configure 1.77s)
    • Test (ctest --preset dev -R 'section_probe' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (1.01s: shader_section_probe_cli_check 0.91s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 55.03s (configure 1.79s)
    • Test (ctest --preset release -R 'section_probe' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.90s: shader_section_probe_cli_check 0.80s)
  • Windows Python checks: tests/resource_ranges_check.py ok (0.6s)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176577278 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2597#issuecomment-7176577278). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T22:36:45Z. --- Win2025 WARP receipt for head a16feab8 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `a16feab8b75030a9547ea140143fddb7023742d9`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `31.26s` (configure `1.77s`) - Test (`ctest --preset dev -R 'section_probe' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`1.01s`: `shader_section_probe_cli_check` `0.91s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `55.03s` (configure `1.79s`) - Test (`ctest --preset release -R 'section_probe' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`0.90s`: `shader_section_probe_cli_check` `0.80s`) - **Windows Python checks**: `tests/resource_ranges_check.py` ok (`0.6s`) AI-assisted; commands listed were executed locally.
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!2589
No description provided.