Add read-only NUP checks that name damaged members #626

Merged
klimovich008 merged 1 commit from codex/verify-nup-members into main 2026-11-08 16:49:22 +00:00
klimovich008 commented 2026-11-08 14:52:05 +00:00 (Migrated from github.com)

What this fixes

Damaged compressed game files can match a NUP's own hashes. The game can then retry those resources continuously, causing high CPU use and stutter, without identifying which files need replacing.

Why merge

  • Opt-in --verify reports title, member path and reason, then returns a failing exit code for damaged input.
  • Check TOC bounds/hash and tree links before scanning; stream member hashes and read shared extents once.
  • Keep normal listing/extraction defaults and legacy compression handling unchanged. Verification writes no extracted files.

Change

nx2/nup.py: add strict metadata checks and read-only member/hash/expected .zs header verification.
nx2/test_nup_verify.py: test valid data, hash-valid damaged headers, checksum failures, dedup, malformed metadata and read-only behavior.
.github/workflows/source-regressions.yml: run the regression on Windows and Linux.

Tested

  • python -I -B nx2/test_nup_verify.py and python -I -B nx2/test_nup_codec.py.
  • Fails on the old code, passes now.
  • Windows/Ryzen 7 5700X3D: the original input reports exactly three bad texture headers in 70 seconds; a replacement passes all 372,587 records in 62 seconds. No game or GPU run is needed.

Not covered

  • Game .zs checks cover Zstd headers only; full inner decoding and asset semantics need separate checks.
  • Hash consistency does not prove authenticity. This command does not repair files.

No game data is included.

## What this fixes Damaged compressed game files can match a NUP's own hashes. The game can then retry those resources continuously, causing high CPU use and stutter, without identifying which files need replacing. ## Why merge - Opt-in `--verify` reports title, member path and reason, then returns a failing exit code for damaged input. - Check TOC bounds/hash and tree links before scanning; stream member hashes and read shared extents once. - Keep normal listing/extraction defaults and legacy compression handling unchanged. Verification writes no extracted files. ## Change `nx2/nup.py`: add strict metadata checks and read-only member/hash/expected `.zs` header verification. `nx2/test_nup_verify.py`: test valid data, hash-valid damaged headers, checksum failures, dedup, malformed metadata and read-only behavior. `.github/workflows/source-regressions.yml`: run the regression on Windows and Linux. ## Tested - `python -I -B nx2/test_nup_verify.py` and `python -I -B nx2/test_nup_codec.py`. - Fails on the old code, passes now. - Windows/Ryzen 7 5700X3D: the original input reports exactly three bad texture headers in 70 seconds; a replacement passes all 372,587 records in 62 seconds. No game or GPU run is needed. ## Not covered - Game `.zs` checks cover Zstd headers only; full inner decoding and asset semantics need separate checks. - Hash consistency does not prove authenticity. This command does not repair files. No game data is included.
Commenting is not possible because the repository is archived.
No description provided.