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

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

@⁠IlyassRS3 on GitHub · 2026-11-25 01:33 UTC · original
IlyassRS3:fix/xtask-policy-magic-utf8-and-symlinks → main · +70 −4 · 1 files · 1 commits · open

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).
**@⁠IlyassRS3** on GitHub · 2026-11-25 01:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/492) `IlyassRS3:fix/xtask-policy-magic-utf8-and-symlinks` → `main` · +70 −4 · 1 files · 1 commits · open ### 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`).
Tightens static Rule #1 enforcement in `xtask/src/policy.rs`:

1. Add console/game/shader/audio magic prefixes to `FORBIDDEN_MAGIC`:
   `RPF7`/`RPF8`/`RPF9`, `SGD5`, `RSC7`/`RSC8`, `FSSM`, `BKHD`, `OggS`,
   ELF (`\x7FELF`), and SPIR-V (`\x03\x02\x23\x07`).
2. Reject non-UTF-8 binary files even when they contain no NUL (`0x00`)
   bytes (verified all 169 existing tracked files except the documented
   `bcpack-tables.bin` exception are valid UTF-8).
3. Reject symbolic links and unreadable files during tree scans instead of
   skipping symlinks in `WalkDir` or silently ignoring `std::fs::read`
   errors on non-deleted paths.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:44:36 +00:00
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/492/head:github-bot/gh-492'
git switch 'github-bot/gh-492'

Merge

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