translate: refuse a VICTORY_EMIT_DUMP directory inside the repo #664
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!664
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/664/head"
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?
@coderanonymus on GitHub · 2026-11-24 06:24 UTC · original
coderanonymus:translate-emit-dump-outside-repo→main· +25 −0 · 1 files · 1 commits · merged 2026-11-25 00:09 UTCWhat
victory translatewrites shader dumps to theVICTORY_EMIT_DUMPdirectory:--list, every emitted shader as<dir>/<label>.dxil;--validate, up to 3 failures per validator reason as<dir>/<reason>_<n>.dxiland<dir>/<reason>_<n>.txt. The.txtholds the shader label (including the game file path) and the validator's full output.The directory was passed straight to
std::fs::writeand never checked withvictory_core::ensure_outside_repo. docs/asset-policy.md lists shader dumps as game-derived and says every writer of derived data must make that check.Bad behaviour, from the repo root:
This writes the dumps into the checkout.
*.dxilis git-ignored, but*.txtis not, andcargo xtask policy --stagedallows small ASCII.txtfiles. Sogit add -Astages the validator reports and the policy check passes them.Change:
translate::runnow callsensure_outside_repoonVICTORY_EMIT_DUMPbefore it starts, so this run fails with the usual "refusing to use ... inside the VIctory source tree" error. It fails early whenever the variable points into the repo, even when neither--listnor--validateis given and nothing would be written. Every dump write is reached fromrun, so one check covers both write sites. Added a test,emit_dump_inside_repo_is_refused, that points the variable at the crate directory, expectsPolicyError::InsideRepo, then unsets the variable.Out of scope: three other dump switches write game-derived data without this check,
VICTORY_CAPTURE(crates/victory-gpu/src/capture.rs),VICTORY_XMA_DUMP(crates/victory-hle/src/modules/audio.rs) andVICTORY_AUDIO_CAPTURE(crates/victory-hle/src/modules/audio/capture.rs). This PR does not cover them.Verification
cargo clippy -p victory --tests --target x86_64-pc-windows-msvc, with and without--features diagnostics: no warnings invictory. One warning invictory-hle(xmem.rs:747) is already on main.rustfmt --edition 2024 --check apps/victory/src/translate.rs: clean.cargo test -p victory-core policy: 4 passed. These cover theensure_outside_repobehaviour the new test relies on.runwalks the missing input path, finds nothing and returnsOk.victory translateagainst a game.No game data used.
🤖 Generated with Claude Code
@lameloball2813-ui on GitHub · 2026-11-24 08:15 UTC · original
Built and ran this on Windows, since the description says it couldn't be: Windows 11, Rust 1.98.1, debug, head
988fd9a.cargo test -p victory: 2 passed, includingtranslate::tests::emit_dump_inside_repo_is_refused. No clippy warnings intranslate.rs.victory translateon a DLL with 326 (PC) shader containers:VICTORY_EMIT_DUMPset to a folder inside the checkout: exits 1 withrefusing to use … for game-derived data: it is inside the VIctory source tree, and the folder isn't created.%TEMP%: runs normally, exit 0.victorybinary that sets or removes an environment variable.VICTORY_EMIT_DUMPis also read invictory-shader'sdiff_tests.rswithout this guard, but those dumps come from the tests' own HLSL rather than from a title, so rule #1 doesn't seem to apply there.@molodayamama on GitHub · 2026-11-24 14:02 UTC · original
Independent Windows check of
988fd9a64718ee9a235cff3b60192b6b86006c4d(Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).cargo test -p victory --locked --bin victory emit_dump_inside_repo_is_refused -- --test-threads=1 --nocapture: 1 passed.The new CLI fixture verifies that
VICTORY_EMIT_DUMPpointing inside the repository is refused. It supplies a path to the guard without running a shader translation.Only source-built synthetic fixtures were used. AI-assisted verification.