translate: refuse a VICTORY_EMIT_DUMP directory inside the repo #664

Merged
coderanonymus merged 1 commit from upstream-pr/664 into main 2026-11-25 00:09:08 +00:00
coderanonymus commented 2026-11-24 06:24:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by coderanonymus on 2026-11-24T06:24:43Z.


What

victory translate writes shader dumps to the VICTORY_EMIT_DUMP directory:

  • with --list, every emitted shader as <dir>/<label>.dxil;
  • with --validate, up to 3 failures per validator reason as <dir>/<reason>_<n>.dxil and <dir>/<reason>_<n>.txt. The .txt holds the shader label (including the game file path) and the validator's full output.

The directory was passed straight to std::fs::write and never checked with victory_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:

VICTORY_EMIT_DUMP=. victory translate --validate --list <game dir>

This writes the dumps into the checkout. *.dxil is git-ignored, but *.txt is not, and cargo xtask policy --staged allows small ASCII .txt files. So git add -A stages the validator reports and the policy check passes them.

Change: translate::run now calls ensure_outside_repo on VICTORY_EMIT_DUMP before 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 --list nor --validate is given and nothing would be written. Every dump write is reached from run, so one check covers both write sites. Added a test, emit_dump_inside_repo_is_refused, that points the variable at the crate directory, expects PolicyError::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) and VICTORY_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 in victory. One warning in victory-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 the ensure_outside_repo behaviour the new test relies on.
  • Not run: the new test itself. apps/victory builds only for Windows, and there is no Windows or Wine here. It type-checks. Before the fix it would fail, because run walks the missing input path, finds nothing and returns Ok.
  • Not run: victory translate against a game.

No game data used.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575997603 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/664). Originally posted by [coderanonymus](https://github.com/coderanonymus) on 2026-11-24T06:24:43Z. --- ## What `victory translate` writes shader dumps to the `VICTORY_EMIT_DUMP` directory: - with `--list`, every emitted shader as `<dir>/<label>.dxil`; - with `--validate`, up to 3 failures per validator reason as `<dir>/<reason>_<n>.dxil` and `<dir>/<reason>_<n>.txt`. The `.txt` holds the shader label (including the game file path) and the validator's full output. The directory was passed straight to `std::fs::write` and never checked with `victory_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: ``` VICTORY_EMIT_DUMP=. victory translate --validate --list <game dir> ``` This writes the dumps into the checkout. `*.dxil` is git-ignored, but `*.txt` is not, and `cargo xtask policy --staged` allows small ASCII `.txt` files. So `git add -A` stages the validator reports and the policy check passes them. Change: `translate::run` now calls `ensure_outside_repo` on `VICTORY_EMIT_DUMP` before 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 `--list` nor `--validate` is given and nothing would be written. Every dump write is reached from `run`, so one check covers both write sites. Added a test, `emit_dump_inside_repo_is_refused`, that points the variable at the crate directory, expects `PolicyError::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) and `VICTORY_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 in `victory`. One warning in `victory-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 the `ensure_outside_repo` behaviour the new test relies on. - Not run: the new test itself. apps/victory builds only for Windows, and there is no Windows or Wine here. It type-checks. Before the fix it would fail, because `run` walks the missing input path, finds nothing and returns `Ok`. - Not run: `victory translate` against a game. No game data used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LAKSHYA-cmd-tech commented 2026-11-24 06:54:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:29:20Z.

Review: APPROVED


LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. cargo test -p victory passed cleanly (2 passed), with emit_dump_inside_repo_is_refused verifying that VICTORY_EMIT_DUMP is prevented from targeting the source checkout in compliance with docs/asset-policy.md.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034677945 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/664#pullrequestreview-6034677945). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:29:20Z. **Review:** APPROVED --- LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. cargo test -p victory passed cleanly (2 passed), with emit_dump_inside_repo_is_refused verifying that VICTORY_EMIT_DUMP is prevented from targeting the source checkout in compliance with docs/asset-policy.md.
catminou4 commented 2026-11-24 06:54:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:42:19Z.

Review: APPROVED


Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin, rust-toolchain.toml):

Main does not compile the app crate on macOS (known host_resource cfg issue, fixed by #235/#523), so I merged #235's head locally (uncommitted, additive conflict in translate.rs resolved by keeping both new modules) purely to run the tests:

  • cargo check -p victory --locked: clean
  • cargo test -p victory --locked: 1 passed, 0 failed — the new emit_dump_inside_repo_is_refused test runs and passes on macOS, confirming the repo-refusal path works outside Windows too.

Approving.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034789866 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/664#pullrequestreview-6034789866). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T06:42:19Z. **Review:** APPROVED --- Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin, rust-toolchain.toml): Main does not compile the app crate on macOS (known `host_resource` cfg issue, fixed by #235/#523), so I merged #235's head locally (uncommitted, additive conflict in translate.rs resolved by keeping both new modules) purely to run the tests: - `cargo check -p victory --locked`: clean - `cargo test -p victory --locked`: **1 passed, 0 failed** — the new `emit_dump_inside_repo_is_refused` test runs and passes on macOS, confirming the repo-refusal path works outside Windows too. Approving.
lameloball2813-ui commented 2026-11-24 09:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by lameloball2813-ui on 2026-11-24T08:15:18Z.


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, including translate::tests::emit_dump_inside_repo_is_refused. No clippy warnings in translate.rs.
  • By hand, victory translate on a DLL with 326 (PC) shader containers:
    • VICTORY_EMIT_DUMP set to a folder inside the checkout: exits 1 with refusing to use … for game-derived data: it is inside the VIctory source tree, and the folder isn't created.
    • Set to a folder under %TEMP%: runs normally, exit 0.
  • The test's SAFETY note holds: it's the only test in the victory binary that sets or removes an environment variable.

VICTORY_EMIT_DUMP is also read in victory-shader's diff_tests.rs without 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7125911390 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/664#issuecomment-7125911390). Originally posted by [lameloball2813-ui](https://github.com/lameloball2813-ui) on 2026-11-24T08:15:18Z. --- 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, including `translate::tests::emit_dump_inside_repo_is_refused`. No clippy warnings in `translate.rs`. - By hand, `victory translate` on a DLL with 326 (PC) shader containers: - `VICTORY_EMIT_DUMP` set to a folder inside the checkout: exits 1 with `refusing to use … for game-derived data: it is inside the VIctory source tree`, and the folder isn't created. - Set to a folder under `%TEMP%`: runs normally, exit 0. - The test's SAFETY note holds: it's the only test in the `victory` binary that sets or removes an environment variable. `VICTORY_EMIT_DUMP` is also read in `victory-shader`'s `diff_tests.rs` without 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 commented 2026-11-24 14:04:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T14:02:44Z.


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_DUMP pointing 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133747734 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/664#issuecomment-7133747734). Originally posted by [molodayamama](https://github.com/molodayamama) on 2026-11-24T14:02:44Z. --- 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_DUMP` pointing 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.
upstream-sync closed this pull request 2026-11-25 01:04:41 +00:00
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
Marvisak/VIctory!664
No description provided.