[pr-fix] xtask policy: an exception waives only the checks it names #415

Open
iBooM72 wants to merge 1 commit from iboom72/policy-per-check-waivers into main AGit
Contributor

What it changes

  • The problem on main: read from the code only. run() in xtask/src/policy.rs (lines 80-82) skips every check for a path in EXCEPTIONS, though each entry's reason names one check. So a PE header or a base64 blob pasted into crates/darner-gpu/src/host.rs (entered for its size) or frame_users.rs (entered for its hex rows) would pass the pre-commit hook.

Each entry now lists the checks it waives, and every other check still runs on that file. The waivers are what each file trips today, checked with a copy of check() over the six paths:

Path Waives
bcpack-tables.bin, docs/darner-logo.png, apps/darner/darner.ico file type, NUL bytes
crates/darner-loader/src/heap_sites/frame_users.rs a long run of \x/0x literals (its rows); a hex/base64 run is still refused
crates/darner-gpu/src/host.rs size
tools/native-dstorage-bridge/bridge.cpp file type

docs/asset-policy.md says so in its enforcement list.

How it was tested

  • Tested revision: 8810faae (on main f3840d73)
  • Commands and results:
    • cargo test -p xtask --locked: 9 passed, including repository_passes_policy (the tree passes with the narrower waivers) and the new an_exception_waives_only_the_checks_it_names (host.rs with 2 MiB of text passes, with a PE header it is refused; frame_users.rs with 1,200 digits of 0x literals passes, with an 800-character base64 run it is refused).
    • cargo clippy -p xtask --all-targets --locked -- -D warnings: clean.
    • cargo xtask policy: 555 files ok.
  • Changes a default: no
  • Gates run on that revision: none of the three workspace gates; the xtask crate's tests and clippy only.
  • Gameplay: not relevant (repository tool).
  • Hardware dependence: none.
  • Coverage gaps: none known.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). It changes only the repository's policy tool.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #72 (merged: the size-limit test in the same file). #349 also edits xtask/src/policy.rs and merges with this branch without a conflict. #376 (wrapped payloads) conflicts with it in one place: its diff also rewrites the em dash in the frame_users.rs reason as —, apparently an encoding slip, on the line this branch changes. Under #376's run rule frame_users.rs still has no run longer than 18, so the two work together once that line is resolved. No open PR touches docs/asset-policy.md.
  • Replaces or overlaps: none found

Checked with AI assistance (Claude Code).

🤖 Generated with Claude Code

<!-- Thanks for the pull request. Start the title with its type (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests) and the area tags, like [pr-fix][memory]. This host has no labels yet, so the tags stay in the title. --> ## What it changes - The problem on main: read from the code only. `run()` in `xtask/src/policy.rs` (lines 80-82) skips every check for a path in `EXCEPTIONS`, though each entry's reason names one check. So a PE header or a base64 blob pasted into `crates/darner-gpu/src/host.rs` (entered for its size) or `frame_users.rs` (entered for its hex rows) would pass the pre-commit hook. Each entry now lists the checks it waives, and every other check still runs on that file. The waivers are what each file trips today, checked with a copy of `check()` over the six paths: | Path | Waives | |---|---| | `bcpack-tables.bin`, `docs/darner-logo.png`, `apps/darner/darner.ico` | file type, NUL bytes | | `crates/darner-loader/src/heap_sites/frame_users.rs` | a long run of `\x`/`0x` literals (its rows); a hex/base64 run is still refused | | `crates/darner-gpu/src/host.rs` | size | | `tools/native-dstorage-bridge/bridge.cpp` | file type | `docs/asset-policy.md` says so in its enforcement list. ## How it was tested - Tested revision: `8810faae` (on `main` `f3840d73`) - Commands and results: - `cargo test -p xtask --locked`: 9 passed, including `repository_passes_policy` (the tree passes with the narrower waivers) and the new `an_exception_waives_only_the_checks_it_names` (`host.rs` with 2 MiB of text passes, with a PE header it is refused; `frame_users.rs` with 1,200 digits of `0x` literals passes, with an 800-character base64 run it is refused). - `cargo clippy -p xtask --all-targets --locked -- -D warnings`: clean. - `cargo xtask policy`: 555 files ok. - Changes a default: no - Gates run on that revision: none of the three workspace gates; the xtask crate's tests and clippy only. - Gameplay: not relevant (repository tool). - Hardware dependence: none. - Coverage gaps: none known. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). It changes only the repository's policy tool. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #72 (merged: the size-limit test in the same file). #349 also edits `xtask/src/policy.rs` and merges with this branch without a conflict. #376 (wrapped payloads) conflicts with it in one place: its diff also rewrites the em dash in the `frame_users.rs` reason as `—`, apparently an encoding slip, on the line this branch changes. Under #376's run rule `frame_users.rs` still has no run longer than 18, so the two work together once that line is resolved. No open PR touches `docs/asset-policy.md`. - Replaces or overlaps: none found Checked with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Each EXCEPTIONS entry now lists the checks it waives (file type, size,
magic, NUL bytes, hex/base64 runs, runs of \x/0x literals). Every other
check still runs on that file, so a PE header pasted into host.rs, or a
base64 blob in frame_users.rs, is refused like anywhere else. The current
tree passes unchanged: each entry waives what it trips today.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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/415/head:iboom72/policy-per-check-waivers'
git switch 'iboom72/policy-per-check-waivers'

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 'iboom72/policy-per-check-waivers'
git switch 'iboom72/policy-per-check-waivers'
git rebase 'main'
git switch 'main'
git merge --ff-only 'iboom72/policy-per-check-waivers'
git switch 'iboom72/policy-per-check-waivers'
git rebase 'main'
git switch 'main'
git merge --no-ff 'iboom72/policy-per-check-waivers'
git switch 'main'
git merge --squash 'iboom72/policy-per-check-waivers'
git switch 'main'
git merge --ff-only 'iboom72/policy-per-check-waivers'
git switch 'main'
git merge 'iboom72/policy-per-check-waivers'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!415
No description provided.