Derived data can be written into the repository: VICTORY_RECORD, replay --images and --retranslate, shaders --list skip ensure_outside_repo #510

Open
opened 2026-11-27 07:59:29 +00:00 by github-bot · 0 comments
Owner

@⁠itsonewi on GitHub · 2026-11-27 07:57 UTC · original

What happens

docs/asset-policy.md makes the runtime check part of rule #1:

  1. At runtime, everything that writes derived data calls
    victory_core::ensure_outside_repo.

docs/asset-policy.md:51-52, with what must never land in the tree spelled out above it: "anything derived from those: converted assets, decompiled or disassembled code, shader dumps, extracted tables, screenshots" (:13-15).

Five places do call it:

  • apps/victory/src/translate.rs:250-255 — the VICTORY_EMIT_DUMP folder: "Dumped shaders and validator reports are game-derived (rule #1)";
  • crates/victory-gpu/src/titlewrite.rs:306-315 — VICTORY_WRITE_SITES's file, with the doc comment "file, if it is outside every source tree: its lines are places in the title's code (docs/asset-policy.md). Said once if not";
  • crates/victory-pipeline/src/cache.rs:39, crates/victory-loader/src/windows.rs:56, and victory config's check (apps/victory/src/main.rs:294).

The write targets that are chosen by hand — where a mistake is most likely, since the default is safe and an explicit path is not — have no check at all:

  1. VICTORY_RECORD=<folder> casts the frame: record.rs:61 takes the folder straight from the environment, :408 makes it (std::fs::create_dir_all(&settings.folder)?), and the capture is written there (shaders.bin at :418, the frame's memory and lists beside it). Nothing looks at where that folder is.
  2. victory replay --images <folder> writes pictures of the title's textures — the "screenshots" of :15: apps/victory/src/replay.rs:309-324 builds play::look::Images { folder: folder.clone(), .. } and hands it to player.images(...).
  3. victory replay --retranslate <folder> writes the title's shader containers and their DXIL — the "shader dumps" of :15: apps/victory/src/replay.rs:441-442 (create_dir_all(&kept), create_dir_all(&into)), :461 ({hash}.cdxil, the container bytes taken out of the title's files) and :482 ({hash}.dxil).
  4. victory shaders --list <file> writes one line per untranslated shader with its hash, the path it was found at and the reason: apps/victory/src/translate.rs:465-470 (std::fs::write(list, …)), while the neighbouring dump of the same run (:250-255) is checked.

grep ensure_outside_repo over the tree returns exactly the five call sites above and none of these four.

Why it matters

The policy's own "If something slips through" section says a follow-up commit is not enough — the history has to be rewritten and everyone re-clones. That is the cost of one VICTORY_RECORD or --images pointed at the working tree (a shell in the repo root, a -More entry in scripts/play.ps1, a --images shots typed where the capture lives), and the recorder is the worst of the four: it writes the frame's recorded memory, gigabytes of it, in one go. cargo xtask policy would then have to catch it before a commit, and it only knows file types, sizes and signatures.

The check already exists, costs one canonicalize per path, and three of these four paths are in code that already refuses other bad input (--retranslate errors on a missing container folder, --images on a bad --texture), so refusing a path inside the tree is a one-line change in each.

Suggested fix

victory_core::ensure_outside_repo(&folder)? before the first write, with the path in the error:

  • crates/victory-gpu/src/replay/record.rs, in Settings::from_env (:58-62) — the recorder cannot return an error, so log it as titlewrite::outside_repo does and record nothing;
  • apps/victory/src/replay.rs, at the top of the --images branch (:309) and at the top of retranslate (:438-442), before either create_dir_all;
  • apps/victory/src/translate.rs, in precompile where --list is written (:465), as run already does for VICTORY_EMIT_DUMP.

A test in the shape of the existing policy tests (a temp dir inside the workspace root is refused, one outside is accepted) would keep the next output path honest.

AI use

Found by an AI agent (Freebuff) reading a-publier through the GitHub API, after deduplicating against the open and closed issues (a search for "outside the repository" returns only #275, #101 and #35, none of them this). Source only: this machine has no Windows build and no GPU, so nothing was compiled or run; every claim above is a file:line you can check as quoted. Filed by the same agent that filed #280–#293, #301, #302 and #311.

**@⁠itsonewi** on GitHub · 2026-11-27 07:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/510) ## What happens `docs/asset-policy.md` makes the runtime check part of rule #1: > 3. At runtime, everything that writes derived data calls > `victory_core::ensure_outside_repo`. `docs/asset-policy.md:51-52`, with what must never land in the tree spelled out above it: "anything derived from those: converted assets, decompiled or disassembled code, shader dumps, extracted tables, screenshots" (`:13-15`). Five places do call it: * `apps/victory/src/translate.rs:250-255` — the `VICTORY_EMIT_DUMP` folder: "Dumped shaders and validator reports are game-derived (rule #1)"; * `crates/victory-gpu/src/titlewrite.rs:306-315` — `VICTORY_WRITE_SITES`'s file, with the doc comment "`file`, if it is outside every source tree: its lines are places in the title's code (docs/asset-policy.md). Said once if not"; * `crates/victory-pipeline/src/cache.rs:39`, `crates/victory-loader/src/windows.rs:56`, and `victory config`'s check (`apps/victory/src/main.rs:294`). The write targets that are chosen by hand — where a mistake is most likely, since the default is safe and an explicit path is not — have no check at all: 1. **`VICTORY_RECORD=<folder>`** casts the frame: `record.rs:61` takes the folder straight from the environment, `:408` makes it (`std::fs::create_dir_all(&settings.folder)?`), and the capture is written there (`shaders.bin` at `:418`, the frame's memory and lists beside it). Nothing looks at where that folder is. 2. **`victory replay --images <folder>`** writes pictures of the title's textures — the "screenshots" of `:15`: `apps/victory/src/replay.rs:309-324` builds `play::look::Images { folder: folder.clone(), .. }` and hands it to `player.images(...)`. 3. **`victory replay --retranslate <folder>`** writes the title's shader containers and their DXIL — the "shader dumps" of `:15`: `apps/victory/src/replay.rs:441-442` (`create_dir_all(&kept)`, `create_dir_all(&into)`), `:461` (`{hash}.cdxil`, the container bytes taken out of the title's files) and `:482` (`{hash}.dxil`). 4. **`victory shaders --list <file>`** writes one line per untranslated shader with its hash, the path it was found at and the reason: `apps/victory/src/translate.rs:465-470` (`std::fs::write(list, …)`), while the neighbouring dump of the same run (`:250-255`) is checked. `grep ensure_outside_repo` over the tree returns exactly the five call sites above and none of these four. ## Why it matters The policy's own "If something slips through" section says a follow-up commit is not enough — the history has to be rewritten and everyone re-clones. That is the cost of one `VICTORY_RECORD` or `--images` pointed at the working tree (a shell in the repo root, a `-More` entry in `scripts/play.ps1`, a `--images shots` typed where the capture lives), and the recorder is the worst of the four: it writes the frame's recorded memory, gigabytes of it, in one go. `cargo xtask policy` would then have to catch it before a commit, and it only knows file types, sizes and signatures. The check already exists, costs one `canonicalize` per path, and three of these four paths are in code that already refuses other bad input (`--retranslate` errors on a missing container folder, `--images` on a bad `--texture`), so refusing a path inside the tree is a one-line change in each. ## Suggested fix `victory_core::ensure_outside_repo(&folder)?` before the first write, with the path in the error: * `crates/victory-gpu/src/replay/record.rs`, in `Settings::from_env` (`:58-62`) — the recorder cannot return an error, so log it as `titlewrite::outside_repo` does and record nothing; * `apps/victory/src/replay.rs`, at the top of the `--images` branch (`:309`) and at the top of `retranslate` (`:438-442`), before either `create_dir_all`; * `apps/victory/src/translate.rs`, in `precompile` where `--list` is written (`:465`), as `run` already does for `VICTORY_EMIT_DUMP`. A test in the shape of the existing policy tests (a temp dir inside the workspace root is refused, one outside is accepted) would keep the next output path honest. ## AI use Found by an AI agent (Freebuff) reading `a-publier` through the GitHub API, after deduplicating against the open and closed issues (a search for "outside the repository" returns only #275, #101 and #35, none of them this). Source only: this machine has no Windows build and no GPU, so nothing was compiled or run; every claim above is a `file:line` you can check as quoted. Filed by the same agent that filed #280–#293, #301, #302 and #311.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 07:59:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.