victory config prints "POLICY VIOLATION" and still exits 0 #301

Closed
opened 2026-11-26 19:49:10 +00:00 by github-bot · 0 comments
Owner

@⁠itsonewi on GitHub · 2026-11-26 19:33 UTC · original

What happens

victory config says it checks the configuration:

    /// Show the resolved configuration and check it.
    Config,

apps/victory/src/main.rs:166-167

and the check is a println! with nothing behind it:

    for p in cfg
        .game_dir
        .iter()
        .chain(&cfg.test_titles)
        .chain([&cfg.cache_dir, &cfg.data_dir])
    {
        if let Err(e) = victory_core::ensure_outside_repo(p) {
            println!("POLICY VIOLATION: {e}");
        }
    }
    Ok(())

apps/victory/src/main.rs:268-278

so Command::Config => show_config(), (apps/victory/src/main.rs:245) hands Ok(()) back to fn main() -> Result<()>, and the process exits 0.

Every other user of the same rule makes it fatal — the command that would use the directory stops:

    // 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))?;
    }

apps/victory/src/translate.rs:250-253

The violation also goes to stdout, mixed into the config file : / game_dir : … lines, so victory config > out.txt or | tee leaves stderr empty and nothing marks the failure.

Why it matters

The one thing the command is for is being run before a run, and a script or a CI step does that as victory config || exit 1 (the README has people check the machine before starting). With the current code that check passes on exactly the configuration ensure_outside_repo exists to refuse — cache_dir, data_dir, game_dir or a test title inside the repository, where the policy says game-derived files must never go. The only sign is a line of prose on stdout that a person has to read and interpret, and victory run / victory translate will then refuse to start with the same path.

Nothing in the tree asserts the exit code, so this can be fixed and tested without touching anything else. (victory config is also the natural place for #285's victory doctor checks to end up; a command that cannot fail is a weak base for that.)

Suggested fix

Collect the violations, print them on stderr, and fail:

    let mut violations = Vec::new();
    for p in cfg.game_dir.iter().chain(&cfg.test_titles).chain([&cfg.cache_dir, &cfg.data_dir]) {
        if let Err(e) = victory_core::ensure_outside_repo(p) {
            violations.push(format!("{}: {e}", p.display()));
        }
    }
    for v in &violations {
        eprintln!("POLICY VIOLATION: {v}");
    }
    anyhow::ensure!(violations.is_empty(), "{} policy violation(s)", violations.len());
    Ok(())

so the resolved values still print first, the violations are on stderr where a shell can separate them, and the exit code is what a script reads.

AI use

Found by an AI agent (Freebuff) reading a-publier at cd8dfc0 through the GitHub API, after checking the open and closed issues for a duplicate. 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.

**@⁠itsonewi** on GitHub · 2026-11-26 19:33 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/301) ## What happens `victory config` says it checks the configuration: ```rust /// Show the resolved configuration and check it. Config, ``` `apps/victory/src/main.rs:166-167` and the check is a `println!` with nothing behind it: ```rust for p in cfg .game_dir .iter() .chain(&cfg.test_titles) .chain([&cfg.cache_dir, &cfg.data_dir]) { if let Err(e) = victory_core::ensure_outside_repo(p) { println!("POLICY VIOLATION: {e}"); } } Ok(()) ``` `apps/victory/src/main.rs:268-278` so `Command::Config => show_config(),` (`apps/victory/src/main.rs:245`) hands `Ok(())` back to `fn main() -> Result<()>`, and the process exits 0. Every other user of the same rule makes it fatal — the command that would *use* the directory stops: ```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))?; } ``` `apps/victory/src/translate.rs:250-253` The violation also goes to **stdout**, mixed into the `config file :` / `game_dir : …` lines, so `victory config > out.txt` or `| tee` leaves stderr empty and nothing marks the failure. ## Why it matters The one thing the command is for is being run before a run, and a script or a CI step does that as `victory config || exit 1` (the README has people check the machine before starting). With the current code that check passes on exactly the configuration `ensure_outside_repo` exists to refuse — `cache_dir`, `data_dir`, `game_dir` or a test title inside the repository, where the policy says game-derived files must never go. The only sign is a line of prose on stdout that a person has to read and interpret, and `victory run` / `victory translate` will then refuse to start with the same path. Nothing in the tree asserts the exit code, so this can be fixed and tested without touching anything else. (`victory config` is also the natural place for #285's `victory doctor` checks to end up; a command that cannot fail is a weak base for that.) ## Suggested fix Collect the violations, print them on stderr, and fail: ```rust let mut violations = Vec::new(); for p in cfg.game_dir.iter().chain(&cfg.test_titles).chain([&cfg.cache_dir, &cfg.data_dir]) { if let Err(e) = victory_core::ensure_outside_repo(p) { violations.push(format!("{}: {e}", p.display())); } } for v in &violations { eprintln!("POLICY VIOLATION: {v}"); } anyhow::ensure!(violations.is_empty(), "{} policy violation(s)", violations.len()); Ok(()) ``` so the resolved values still print first, the violations are on stderr where a shell can separate them, and the exit code is what a script reads. ## AI use Found by an AI agent (Freebuff) reading `a-publier` at `cd8dfc0` through the GitHub API, after checking the open and closed issues for a duplicate. 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:49:10 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.