xtask/policy: detect game/shader magics, non-UTF-8 binaries, and symlinks #492

Open
IlyassRS3 wants to merge 1 commit from upstream-pr/492 into main
IlyassRS3 commented 2026-11-25 01:33:28 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by IlyassRS3 on 2026-11-25T01:33:28Z.


Summary

Tightens static Rule #1 enforcement in xtask/src/policy.rs (cargo xtask policy):

  1. Additional game/console/shader/audio magic signatures: adds RPF7/RPF8/RPF9 (RAGE packfiles), SGD5 (engine shader archives), RSC7/RSC8 (RAGE resources), FSSM (Xbox shader binaries), BKHD (Wwise soundbanks), OggS (Ogg audio), ELF (ELF binaries), and # (SPIR-V binaries) to FORBIDDEN_MAGIC.
  2. Non-UTF-8 binary rejection without NUL bytes: previously check() only tested content.contains(&0), letting raw non-UTF-8 binary content without 0x00 bytes pass if given an allowlisted extension such as .txt. Non-UTF-8 content is now explicitly rejected (all 169 existing repository files except the documented bcpack-tables.bin exception are valid UTF-8).
  3. Symbolic link and unreadable-file enforcement: previously WalkDir filtered out symlinks (is_file() only) and run() silently ignored any std::fs::read error (Err(_) => continue). run() now flags symlinks as policy violations and reports read/metadata errors on existing files (while still skipping deleted tracked files on NotFound and directory/submodule entries).

Verification

  • AI-assisted: Yes (written and verified with AI assistance).
  • Environment: macOS arm64 (Apple M5), CPU-only, Rust 1.98.1, no Windows GPU / no game files.
  • cargo test --locked -p xtask: 6 passed, 0 failed (including repository_passes_policy and 2 new tests: rejects_game_archive_magics_and_non_utf8_binary_without_nuls, rejects_symlinks_in_tree).
  • cargo clippy --locked -p xtask --all-targets -- -D warnings: 0 warnings.
  • cargo clippy --locked -p xtask --all-targets --target x86_64-pc-windows-msvc -- -D warnings and --all-features: 0 warnings.
  • Mutation check on unpatched upstream/main (a803c87): both new tests fail on unpatched xtask/src/policy.rs (4 passed; 2 failed).
<!-- greyfinch-sync:fxceless/victory-fork:issue:6595074885 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/492). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T01:33:28Z. --- ### Summary Tightens static Rule #1 enforcement in `xtask/src/policy.rs` (`cargo xtask policy`): 1. **Additional game/console/shader/audio magic signatures**: adds `RPF7`/`RPF8`/`RPF9` (RAGE packfiles), `SGD5` (engine shader archives), `RSC7`/`RSC8` (RAGE resources), `FSSM` (Xbox shader binaries), `BKHD` (Wwise soundbanks), `OggS` (Ogg audio), `ELF` (ELF binaries), and `#` (SPIR-V binaries) to `FORBIDDEN_MAGIC`. 2. **Non-UTF-8 binary rejection without NUL bytes**: previously `check()` only tested `content.contains(&0)`, letting raw non-UTF-8 binary content without `0x00` bytes pass if given an allowlisted extension such as `.txt`. Non-UTF-8 content is now explicitly rejected (all 169 existing repository files except the documented `bcpack-tables.bin` exception are valid UTF-8). 3. **Symbolic link and unreadable-file enforcement**: previously `WalkDir` filtered out symlinks (`is_file()` only) and `run()` silently ignored any `std::fs::read` error (`Err(_) => continue`). `run()` now flags symlinks as policy violations and reports read/metadata errors on existing files (while still skipping deleted tracked files on `NotFound` and directory/submodule entries). ### Verification - **AI-assisted**: Yes (written and verified with AI assistance). - **Environment**: macOS arm64 (Apple M5), CPU-only, Rust `1.98.1`, no Windows GPU / no game files. - `cargo test --locked -p xtask`: **6 passed, 0 failed** (including `repository_passes_policy` and 2 new tests: `rejects_game_archive_magics_and_non_utf8_binary_without_nuls`, `rejects_symlinks_in_tree`). - `cargo clippy --locked -p xtask --all-targets -- -D warnings`: **0 warnings**. - `cargo clippy --locked -p xtask --all-targets --target x86_64-pc-windows-msvc -- -D warnings` and `--all-features`: **0 warnings**. - **Mutation check on unpatched `upstream/main` (`a803c87`)**: both new tests fail on unpatched `xtask/src/policy.rs` (`4 passed; 2 failed`).
copilot-pull-request-reviewer[bot commented 2026-11-25 02:09:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T01:33:45Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:fxceless/victory-fork:review:6050222761 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/492#pullrequestreview-6050222761). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-25T01:33:45Z. **Review:** COMMENTED --- 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/492:upstream-pr/492'
git switch 'upstream-pr/492'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/492'
git switch 'upstream-pr/492'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/492'
git switch 'upstream-pr/492'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/492'
git switch 'main'
git merge --squash 'upstream-pr/492'
git switch 'main'
git merge --ff-only 'upstream-pr/492'
git switch 'main'
git merge 'upstream-pr/492'
git push origin 'main'
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
fxceless/victory-fork!492
No description provided.