CLI: refuse VICTORY_PREBUILD_KEYS paths inside the repository #3042

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/3044 into main
fuzeofficlal commented 2026-11-26 05:12:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:12:24Z.


Problem

apps/victory/src/prebuild.rs reads VICTORY_PREBUILD_KEYS=<file> and writes game-derived pipeline keys and shader hashes directly via std::fs::write, without calling victory_core::ensure_outside_repo. Setting a repo-relative path such as VICTORY_PREBUILD_KEYS=keys.txt from the checkout root writes game-derived output into the repository tree (and truncates any existing file at that path), unlike VICTORY_EMIT_DUMP in apps/victory/src/translate.rs.

Fix

  • Validate VICTORY_PREBUILD_KEYS via victory_core::ensure_outside_repo at the start of prebuild::run (before scanning files or touching caches/outputs).
  • Add a unit test (prebuild_keys_inside_repo_is_refused) verifying that None passes, a path inside the repository is rejected, and a path outside the repository is accepted.

Verification

  • cargo test --locked -p victory (15 unit tests + 4 integration tests passed)
  • cargo clippy --locked -p victory --all-targets -- -D warnings
  • rustfmt --edition 2024 --check apps/victory/src/prebuild.rs
  • cargo xtask policy (191 files ok)
<!-- greyfinch-sync:Marvisak/VIctory:issue:5504402883 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3044). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T05:12:24Z. --- ### Problem `apps/victory/src/prebuild.rs` reads `VICTORY_PREBUILD_KEYS=<file>` and writes game-derived pipeline keys and shader hashes directly via `std::fs::write`, without calling `victory_core::ensure_outside_repo`. Setting a repo-relative path such as `VICTORY_PREBUILD_KEYS=keys.txt` from the checkout root writes game-derived output into the repository tree (and truncates any existing file at that path), unlike `VICTORY_EMIT_DUMP` in `apps/victory/src/translate.rs`. ### Fix - Validate `VICTORY_PREBUILD_KEYS` via `victory_core::ensure_outside_repo` at the start of `prebuild::run` (before scanning files or touching caches/outputs). - Add a unit test (`prebuild_keys_inside_repo_is_refused`) verifying that `None` passes, a path inside the repository is rejected, and a path outside the repository is accepted. ### Verification - `cargo test --locked -p victory` (15 unit tests + 4 integration tests passed) - `cargo clippy --locked -p victory --all-targets -- -D warnings` - `rustfmt --edition 2024 --check apps/victory/src/prebuild.rs` - `cargo xtask policy` (191 files ok)
kotekompotek commented 2026-11-26 05:25:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T05:25:30Z.

Review: APPROVED


Verified: keys_output_path routes the env path through ensure_outside_repo — the asset-policy requirement for runtime writes — and rejects before any work starts rather than after the scan. Test covers the inside/outside/unset cases.

<!-- greyfinch-sync:Marvisak/VIctory:review:6068965678 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3044#pullrequestreview-6068965678). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T05:25:30Z. **Review:** APPROVED --- Verified: `keys_output_path` routes the env path through `ensure_outside_repo` — the asset-policy requirement for runtime writes — and rejects before any work starts rather than after the scan. Test covers the inside/outside/unset cases.
Marvisak commented 2026-11-26 07:01:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:17:21Z.


Automated triage for the maintainers.

prebuild::run (apps/victory/src/prebuild.rs) writes game-derived pipeline keys and shader hashes to VICTORY_PREBUILD_KEYS with std::fs::write. It never called victory_core::ensure_outside_repo, unlike every other place that writes game-derived output (translate.rs for VICTORY_EMIT_DUMP, main.rs, config.rs, victory-pipeline's cache). The PR checks the path first, before any file is scanned or written. That supports the asset policy. The later uses of keys_only (the is_some() checks and the final write) work unchanged with the new Option<PathBuf>. The test's expected text matches PolicyError::InsideRepo's message. CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184281448 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3044#issuecomment-7184281448). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:17:21Z. --- <!-- victory-triage v1 head=66ca71ba4cd5ac3d412dc71961fd6864f8693591 verdict=merge-candidate at=2026-11-26T06:39:00Z --> Automated triage for the maintainers. `prebuild::run` (`apps/victory/src/prebuild.rs`) writes game-derived pipeline keys and shader hashes to `VICTORY_PREBUILD_KEYS` with `std::fs::write`. It never called `victory_core::ensure_outside_repo`, unlike every other place that writes game-derived output (`translate.rs` for `VICTORY_EMIT_DUMP`, `main.rs`, `config.rs`, `victory-pipeline`'s cache). The PR checks the path first, before any file is scanned or written. That supports the asset policy. The later uses of `keys_only` (the `is_some()` checks and the final write) work unchanged with the new `Option<PathBuf>`. The test's expected text matches `PolicyError::InsideRepo`'s message. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 08:32:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T08:32:43Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory -- --test-threads=1: 15 lib + 4 integration tests passed (including prebuild::tests::prebuild_keys_inside_repo_is_refused).
  • cargo clippy -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly prevents VICTORY_PREBUILD_KEYS from pointing inside the repository, matching the existing repo-path safeguards.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6070757239 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3044#pullrequestreview-6070757239). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T08:32:43Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory -- --test-threads=1`: 15 lib + 4 integration tests passed (including `prebuild::tests::prebuild_keys_inside_repo_is_refused`). - `cargo clippy -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly prevents `VICTORY_PREBUILD_KEYS` from pointing inside the repository, matching the existing repo-path safeguards. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 19:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T19:03:29Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 66ca71b (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: prebuild_keys_inside_repo_is_refused.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7201149068 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3044#issuecomment-7201149068). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T19:03:29Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `66ca71b` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `prebuild_keys_inside_repo_is_refused`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3044:upstream-pr/3044'
git switch 'upstream-pr/3044'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3044'
git switch 'upstream-pr/3044'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3044'
git switch 'upstream-pr/3044'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3044'
git switch 'main'
git merge --squash 'upstream-pr/3044'
git switch 'main'
git merge --ff-only 'upstream-pr/3044'
git switch 'main'
git merge 'upstream-pr/3044'
git push origin 'main'
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!3042
No description provided.