From 236d42c78d36908840b3d86af4a566b2692aaddf Mon Sep 17 00:00:00 2001 From: LF2000 Builder Date: Tue, 24 Nov 2026 00:37:04 -0500 Subject: [PATCH] translate: refuse a VICTORY_EMIT_DUMP directory inside the repo translate writes emitted DXIL and validator reports to the VICTORY_EMIT_DUMP directory. Both are derived from the game's shaders, but the directory was never checked against the source tree. With VICTORY_EMIT_DUMP=. run from the checkout, the .txt reports land in the repo, and git and cargo xtask policy both let them through. Check the directory once at the start of translate::run, as Config already does for the cache and data directories. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 988fd9a64718ee9a235cff3b60192b6b86006c4d) --- apps/viport/src/translate.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apps/viport/src/translate.rs b/apps/viport/src/translate.rs index 6ca0875..f1c7929 100644 --- a/apps/viport/src/translate.rs +++ b/apps/viport/src/translate.rs @@ -168,6 +168,10 @@ pub fn run( list: bool, jobs: Option, ) -> Result<()> { + // Dumped shaders and validator reports are game-derived (rule #1). + if let Some(dir) = std::env::var_os("VIPORT_EMIT_DUMP") { + viport_core::ensure_outside_repo(Path::new(&dir))?; + } let paths = crate::default_paths(paths)?; let dll = validate.then(Validator::default_path).flatten(); if validate { @@ -1035,4 +1039,22 @@ Validation failed."; } } } + + /// Shader dumps are game-derived, so a dump directory in the repo is refused. + #[test] + fn emit_dump_inside_repo_is_refused() { + // SAFETY: no other test in this binary touches the environment. + unsafe { std::env::set_var("VIPORT_EMIT_DUMP", env!("CARGO_MANIFEST_DIR")) }; + let missing = std::env::temp_dir().join("viport-translate-no-such-dir"); + let err = super::run(vec![missing], false, false, false, Some(1)).unwrap_err(); + // SAFETY: as above; unset so a later test's `run` is not refused. + unsafe { std::env::remove_var("VIPORT_EMIT_DUMP") }; + assert!( + matches!( + err.downcast_ref(), + Some(viport_core::PolicyError::InsideRepo { .. }) + ), + "{err}" + ); + } }