fix(translate): keep the other two shader dumps out of the repo #434

Manually merged
github merged 1 commit from github-bot/gh-434 into main 2026-12-04 03:42:17 +00:00 AGit
Owner

@⁠Luxuride on GitHub · 2026-12-04 02:44 UTC · original
Luxuride:fix/dump-outside-repo → main · +37 −0 · 1 files · 1 commits · merged 2026-12-04 03:42 UTC

What is wrong

crates/victory-core/src/policy.rs:1-6 states rule #1: anything produced from the user's files is as much "from the game" as the files themselves, and every tool that writes such output must call ensure_outside_repo on the destination first.

apps/victory/src/translate.rs:269-275 says exactly that, then checks one of three destinations:

    // Dumped shaders and validator reports are game-derived (rule #1).
    if let Some(dir) = std::env::var_os("VICTORY_EMIT_DUMP") {
        victory_core::ensure_outside_repo(Path::new(&dir))?;
    }

The two below it write the same bytes — &bytes[..], the title's own .cdxil container — with no check:

  • apps/victory/src/translate.rs:582-605, VICTORY_DUMP_MATCH=<dir>;<text>|…
  • apps/victory/src/translate.rs:617-635, VICTORY_FAIL_DUMP=<dir>, which also swallows every error with let _ =.

Concrete failure

From a clone (the cwd ./run.sh uses):

VICTORY_FAIL_DUMP=$PWD ./run.sh translate <game-dir>

fills the working tree with the title's shader containers, silently. The static half of rule #1 (cargo xtask policy) only inspects tracked files, so nothing complains until git add -A, at which point game data becomes a candidate commit — the one thing the policy exists to prevent. The identical VICTORY_EMIT_DUMP=$PWD is refused with PolicyError::InsideRepo, so three neighbours in one function behave two ways.

The change

Check all three destinations up front, where the existing one already is:

    // So are the containers these two write: the title's own `.cdxil` bytes.
    if let Some(spec) = std::env::var("VICTORY_DUMP_MATCH").ok().as_deref()
        && let Some((dir, _)) = spec.split_once(';')
    {
        victory_core::ensure_outside_repo(Path::new(dir))?;
    }
    if let Some(dir) = std::env::var_os("VICTORY_FAIL_DUMP") {
        victory_core::ensure_outside_repo(Path::new(&dir))?;
    }

Checking early also means the refusal happens before any container has been translated, not after the first match.

Plus a regression test next to the existing emit_dump_inside_repo_is_refused: it sets each variable in turn to CARGO_MANIFEST_DIR and asserts run fails with PolicyError::InsideRepo. One test for both, so the two cannot race each other on the environment.

Validation

  • cargo check -p victory --tests --target x86_64-pc-windows-msvc — Finished (the test harness included). The crate cannot run natively here: victory-loader needs windows_sys.
  • grep -c ensure_outside_repo apps/victory/src/translate.rs: 1 → 3.
  • cargo test -p victory-core policy:: passes on this host, which is the function the new calls land in (refuses CARGO_MANIFEST_DIR with InsideRepo).
  • Unpatched, the new test fails with run returning Ok — walkdir failures are dropped by filter_map(Result::ok), so an unguarded dump directory produces no error at all.

Overlap

Checked every open PR that touches apps/victory/src/translate.rs (ray-tracing and translate work): none adds or moves an ensure_outside_repo call or mentions VICTORY_FAIL_DUMP/VICTORY_DUMP_MATCH. No issue mentions either variable or rule #1.

victory shaders --list <path> (apps/victory/src/translate.rs:490) writes a text listing of hashes and game paths, not container bytes; leaving it out keeps this to the data the rule names.

**@⁠Luxuride** on GitHub · 2026-12-04 02:44 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/434) `Luxuride:fix/dump-outside-repo` → `main` · +37 −0 · 1 files · 1 commits · merged 2026-12-04 03:42 UTC ### What is wrong `crates/victory-core/src/policy.rs:1-6` states rule #1: anything produced from the user's files is as much "from the game" as the files themselves, and **every** tool that writes such output must call `ensure_outside_repo` on the destination first. `apps/victory/src/translate.rs:269-275` says exactly that, then checks one of three destinations: ```rust // Dumped shaders and validator reports are game-derived (rule #1). if let Some(dir) = std::env::var_os("VICTORY_EMIT_DUMP") { victory_core::ensure_outside_repo(Path::new(&dir))?; } ``` The two below it write the same bytes — `&bytes[..]`, the title's own `.cdxil` container — with no check: - `apps/victory/src/translate.rs:582-605`, `VICTORY_DUMP_MATCH=<dir>;<text>|…` - `apps/victory/src/translate.rs:617-635`, `VICTORY_FAIL_DUMP=<dir>`, which also swallows every error with `let _ =`. ### Concrete failure From a clone (the cwd `./run.sh` uses): ``` VICTORY_FAIL_DUMP=$PWD ./run.sh translate <game-dir> ``` fills the working tree with the title's shader containers, silently. The static half of rule #1 (`cargo xtask policy`) only inspects *tracked* files, so nothing complains until `git add -A`, at which point game data becomes a candidate commit — the one thing the policy exists to prevent. The identical `VICTORY_EMIT_DUMP=$PWD` is refused with `PolicyError::InsideRepo`, so three neighbours in one function behave two ways. ### The change Check all three destinations up front, where the existing one already is: ```rust // So are the containers these two write: the title's own `.cdxil` bytes. if let Some(spec) = std::env::var("VICTORY_DUMP_MATCH").ok().as_deref() && let Some((dir, _)) = spec.split_once(';') { victory_core::ensure_outside_repo(Path::new(dir))?; } if let Some(dir) = std::env::var_os("VICTORY_FAIL_DUMP") { victory_core::ensure_outside_repo(Path::new(&dir))?; } ``` Checking early also means the refusal happens before any container has been translated, not after the first match. Plus a regression test next to the existing `emit_dump_inside_repo_is_refused`: it sets each variable in turn to `CARGO_MANIFEST_DIR` and asserts `run` fails with `PolicyError::InsideRepo`. One test for both, so the two cannot race each other on the environment. ### Validation - `cargo check -p victory --tests --target x86_64-pc-windows-msvc` — `Finished` (the test harness included). The crate cannot run natively here: `victory-loader` needs `windows_sys`. - `grep -c ensure_outside_repo apps/victory/src/translate.rs`: 1 → 3. - `cargo test -p victory-core policy::` passes on this host, which is the function the new calls land in (refuses `CARGO_MANIFEST_DIR` with `InsideRepo`). - Unpatched, the new test fails with `run` returning `Ok` — walkdir failures are dropped by `filter_map(Result::ok)`, so an unguarded dump directory produces no error at all. ### Overlap Checked every open PR that touches `apps/victory/src/translate.rs` (ray-tracing and translate work): none adds or moves an `ensure_outside_repo` call or mentions `VICTORY_FAIL_DUMP`/`VICTORY_DUMP_MATCH`. No issue mentions either variable or rule #1. `victory shaders --list <path>` (`apps/victory/src/translate.rs:490`) writes a text listing of hashes and game paths, not container bytes; leaving it out keeps this to the data the rule names.
Rule #1 says every tool that writes game-derived data calls
ensure_outside_repo on the destination first, and the run prologue says so
in a comment while guarding only VICTORY_EMIT_DUMP. VICTORY_DUMP_MATCH and
VICTORY_FAIL_DUMP write the same '.cdxil' container bytes unguarded, and
VICTORY_FAIL_DUMP swallows its write errors, so from the repo root a
developer chasing a translator gap fills the working tree with the title's
shader containers in silence until git add -A.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 02:49:08 +00:00
github manually merged commit 829ef5fb45 into main 2026-12-04 03:42:16 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.