xtask: reject decimal byte arrays in the asset policy #2246
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2246
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2246"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@xiaotu030202 on GitHub · 2026-11-25 08:46 UTC · original
xiaotu030202:xtask/policy-decimal-byte-arrays→main· +123 −1 · 1 files · 1 commits · openWhat this does
xtask's asset policy catches copied data in text by shape: a long hex/base64run, or a long run of
\xNN/0xNNliterals. A[u8]dump written as plaindecimal literals passes both, and the source said so:
This adds the rule and drops the note.
How
longest_decimal_run(new, next tolongest_hex_literal_run) walks the fileand counts byte-range literals in one unbroken run. A literal counts when it is
0,7,255count;007does not),1u8,0.5do not count),,, spaces, tabs or newlines.checkrejects a run longer thanMAX_ENCODED_RUN, the same 512 the two hexrules use, with the message
A run of digits longer than three is skipped rather than folded: it cannot be a
byte, and folding an address or a hash overflows
u32.Why counted in literals, not digits
Digits would reject tables the tree needs:
crates/victory-formats/src/xma/tables.rsholds
COEF0_LENS(272 byte-sized entries) andCOEF0_SYMS(272 indices).cargo xtask policyover the whole tree:The worst run anywhere is 272, so 512 leaves the existing tables alone with room
to spare while still catching an actual dump (4096 bytes is 4095-4096 literals).
Tests
Two new tests in
xtask/src/policy.rs:rejects_data_smuggled_as_a_decimal_byte_array— 4096 synthetic bytes asdecimal literals, both comma-separated on one line and one entry per line.
The one-line form asserts the specific message, so a different rule firing
would not make it pass silently.
accepts_tables_of_small_decimals—COEF0_LENS-shaped (272 byte-sizedentries) and
COEF0_SYMS-shaped (272 indices) tables still pass, and so do1u8suffixes, fractions and leading zeros, which are not byte literals.Both use the existing
synthetichelper, so nothing from the game is involved.Verification
On the pinned 1.98.1, with the MSVC build tools:
Worth noting:
repository_passes_policyis what caught the overflow while I waswriting this — a smaller test set would not have. It is the reason the fold is
guarded above.
Also clean:
cargo clippy -p xtask --all-targets— no warningscargo xtask policy—182 files okrustfmt --edition 2024 --check xtask/src/policy.rsNothing here touches game data.
`check` catches copied data in text by shape: a long hex/base64 run, or a long run of `\xNN`/`0xNN` literals. A `[u8]` dump written as plain decimal literals passes both, so the note shortcut: decimal arrays (`[77, 90, ...]`) still pass, add a literal count if one shows up. stood in for the rule. Add it. `longest_decimal_run` counts byte-range literals (at most three digits, no leading zero, no type suffix or fraction, nothing but a separator between them) in one unbroken run, and `check` rejects a run longer than `MAX_ENCODED_RUN`, the limit the hex rules already use. Counted in literals rather than digits, so the tables a decoder needs stay legal: the largest byte-sized table in the tree is `COEF0_LENS` at 272 entries, and the whole tree peaks at 272, well under 512. Tests: the `[77, 90, ...]` shape is now rejected both comma-separated on one line and one entry per line; `COEF0_LENS`- and `COEF0_SYMS`-shaped tables still pass, as do `1u8` suffixes, fractions and leading zeros. Signed-off-by: xiaotu030202 <[email protected]>@kotekompotek on GitHub · 2026-11-25 09:25 UTC · original
Ran
cargo xtask policyon this branch (Windows):asset policy: 182 files ok— no false positives from the decimal-run rule.Read through
longest_decimal_run: the literal shape is right — ≤3 digits, no leading zero, separator-only adjacency, and a value cap at 0xFF so256-class entries can't extend a run. Counting literals rather than digits correctly leavesCOEF0_LENS/COEF0_SYMS(272 entries) under the 512 limit, and digit runs longer than three (123456789in hashes/addresses) bail before the fold so nothing overflows.@cloph-dsp on GitHub · 2026-11-25 10:29 UTC · original
Independent local verification (Windows, Rust 1.100.0 / MSVC, no game data, no GPU) at head
e18c766:cargo test -p xtask --locked— 8 tests passed, including the newrejects_data_smuggled_as_a_decimal_byte_arrayandaccepts_tables_of_small_decimals.cargo xtask policy—asset policy: 182 files ok, exit 0.cargo test --workspace --locked— exit 0 (all doc-tests ok).The decimal-byte-array detection does not trip the repo policy scan on this tree. I did not check false positives against game-derived numeric tables (no game files present); the synthetic negative-control style tests above are the extent of my validation. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only Rust tooling). No assets, executables or extracted data used.
@Marvisak on GitHub · 2026-11-25 13:31 UTC · original · edited 2026-11-25 16:46 UTC
Automated triage for the maintainers.
Merge candidate (worth a look). This closes the
shortcut:noted inxtask/src/policy.rs, where decimal byte arrays passed the asset policy. It addslongest_decimal_run, which counts runs of bare byte-sized decimal literals and rejects any run over the existingMAX_ENCODED_RUN(512). It only tightens the allowlist. I checked that the largest table in the tree, incrates/victory-formats/src/xma/tables.rs, stays under the limit. Two contributors reportcargo xtask policyclean on this branch, and the branch merges cleanly.On your reply: confirmed. There are no check runs on this head yet because the workflow is waiting for maintainer approval (first-time contributor), not because it's missing. A maintainer should approve the run before merging.
Generated by Claude Code
@xiaotu030202 on GitHub · 2026-11-25 15:38 UTC · original
The triage note says "CI has not run on this head, so a maintainer should start it before merging." One detail that may save someone time:
CI did run — it is waiting for approval, not missing.
action_requiredis GitHub's first-time-contributor gate: a workflow triggered by apull_requestfrom a fork needs a maintainer to approve it once, and until then it shows as neither queued nor failed. There is a "Review deployments / Approve and run" button on the run page, or Settings → Actions → "Require approval for first-time contributors" can be relaxed.So nothing is stuck — someone with write access just has to click approve and the existing
ci.ymlwill run one18c766. I cannot approve it myself (no write access to the base repo, and the approval is deliberately not delegable).The other two local reports stand as they are:
cargo xtask policyclean at 182 files,cargo test -p xtask --locked8 passed,cargo test --workspace --lockedexit 0. Those were run on this branch by @kotekompotek and @cloph-dsp, so the merge decision does not depend on the CI result — it is a second opinion, not the only one.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.