fix(core): refuse a data_dir inside the cache_dir #224

Open
github-bot wants to merge 1 commit from github-bot/gh-224 into main AGit
Owner

@⁠mutlusinan on GitHub · 2026-11-27 19:53 UTC · original
mutlusinan:fix/core-data-dir-guard → main · +48 −1 · 2 files · 1 commits · open

Problem

data_dir could be set to the cache_dir or to a folder inside it. The cache may be deleted at any time, so saves and settings kept there would go with it, silently.

Fix

Config::resolve refuses a data_dir that is the cache_dir or lies inside it. victory_core::policy::is_within compares resolved whole path components (after symlinks and .., neither path needing to exist), so a sibling such as cache-old is still accepted, and a cache inside the data folder stays allowed.

Verification

  • cargo test -p victory-core — 16 passed, 0 failed, including data_dir_equal_to_cache_dir_is_refused, data_dir_inside_cache_dir_is_refused and sibling_with_similar_prefix_and_cache_inside_data_are_allowed.
  • cargo check --workspace --target x86_64-pc-windows-msvc --locked — clean.

Ported from uiliannn/VItoriaBr 30d9ba1 (pull requests #38 and #42), GPL-3.0.

**@⁠mutlusinan** on GitHub · 2026-11-27 19:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/224) `mutlusinan:fix/core-data-dir-guard` → `main` · +48 −1 · 2 files · 1 commits · open ### Problem `data_dir` could be set to the `cache_dir` or to a folder inside it. The cache may be deleted at any time, so saves and settings kept there would go with it, silently. ### Fix `Config::resolve` refuses a `data_dir` that is the `cache_dir` or lies inside it. `victory_core::policy::is_within` compares resolved whole path components (after symlinks and `..`, neither path needing to exist), so a sibling such as `cache-old` is still accepted, and a cache inside the data folder stays allowed. ### Verification - `cargo test -p victory-core` — **16 passed, 0 failed**, including `data_dir_equal_to_cache_dir_is_refused`, `data_dir_inside_cache_dir_is_refused` and `sibling_with_similar_prefix_and_cache_inside_data_are_allowed`. - `cargo check --workspace --target x86_64-pc-windows-msvc --locked` — clean. Ported from uiliannn/VItoriaBr `30d9ba1` (pull requests #38 and #42), GPL-3.0.
The cache may be deleted at any time; saves and settings kept inside it
would go with it. `is_within` compares resolved whole components, so a
sibling such as `cache-old` is still accepted, and a cache inside the
data folder remains allowed.

Ported from uiliannn/VItoriaBr 30d9ba1 (pull requests #38 and #42).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:58:39 +00:00
Author
Owner

@⁠mutlusinan on GitHub · 2026-11-27 20:21 UTC · original

Risk assessment (porting review)

  • Defaults are siblings (%LOCALAPPDATA%/victory/cache and .../data), so no default installation is affected.
  • Behavior change: a victory.toml or environment that puts data_dir inside cache_dir now fails at startup with an explicit message instead of running (and losing saves whenever the cache is cleared). Intended, but it is a hard failure for those setups rather than a warning.
  • is_within resolves symlinks and .. without requiring either path to exist; a sibling with a common prefix (cache-old) and a cache inside the data folder are still accepted (tests cover both).
  • Compatibility: merges cleanly and type-checks against main at e69e39c.
**@⁠mutlusinan** on GitHub · 2026-11-27 20:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/224#issuecomment-7227421364) ### Risk assessment (porting review) - Defaults are siblings (`%LOCALAPPDATA%/victory/cache` and `.../data`), so no default installation is affected. - **Behavior change:** a `victory.toml` or environment that puts `data_dir` inside `cache_dir` now fails at startup with an explicit message instead of running (and losing saves whenever the cache is cleared). Intended, but it is a hard failure for those setups rather than a warning. - `is_within` resolves symlinks and `..` without requiring either path to exist; a sibling with a common prefix (`cache-old`) and a cache inside the data folder are still accepted (tests cover both). - **Compatibility:** merges cleanly and type-checks against `main` at `e69e39c`.
Author
Owner

@⁠1tsethan on GitHub · 2026-11-27 23:00 UTC · original

Independent Windows validation of PR #224.

Tested commit: 0f52dbd892f2e9af7a84e0edc9bec635ec42dc32.

cargo test --locked -p victory-core

Exit: 0.

  • test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Independent verification with OpenAI Codex assistance. Windows 11 Pro build 26200; Rust 1.98.1 MSVC; Windows SDK libraries from Microsoft.Windows.SDK.CPP.x64 10.0.28000.2957. Test harness used an RTX 3070 Ti / AMD integrated-GPU host; adapter identity was not captured for every test. These are focused checks on the stated PR commit, not gameplay, FPS, or a merged-main integration result.

**@⁠1tsethan** on GitHub · 2026-11-27 23:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/224#issuecomment-7229796085) Independent Windows validation of PR #224. Tested commit: `0f52dbd892f2e9af7a84e0edc9bec635ec42dc32`. `cargo test --locked -p victory-core` Exit: **0**. - test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Independent verification with OpenAI Codex assistance. Windows 11 Pro build 26200; Rust 1.98.1 MSVC; Windows SDK libraries from Microsoft.Windows.SDK.CPP.x64 10.0.28000.2957. Test harness used an RTX 3070 Ti / AMD integrated-GPU host; adapter identity was not captured for every test. These are focused checks on the stated PR commit, not gameplay, FPS, or a merged-main integration result. <!-- victory-native-validation-20261128 -->
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 23:49 UTC · original

Independent local verification of PR #224 (refuse a data_dir equal to or inside the cache_dir).

  • Windows, Rust 1.100.0/MSVC (Scoop rust-msvc, no rustup/clippy), cargo test --locked, synthetic inputs only.
  • Head 0f52dbd892f2e9af7a84e0edc9bec635ec42dc32, merge base 0cef07e9d766df48f0e95f13ce3bbbe2290fe9d3, worktree-local CARGO_TARGET_DIR.
  • Commands:
    • cargo test --locked -p victory-core --lib -- config::tests::data_dir_inside_cache_dir_is_refused --exact --test-threads=1 --quiet → test result: ok. 1 passed; 0 failed; 15 filtered out, exit 0.
    • cargo test --locked -p victory-core --lib -- config::tests --quiet → test result: ok. 11 passed; 0 failed; 5 filtered out, exit 0 (includes the sibling tests data_dir_equal_to_cache_dir_is_refused and sibling_with_similar_prefix_and_cache_inside_data_are_allowed).
  • Negative control: git grep -F data_dir_inside_cache_dir_is_refused 0cef07e9 -- crates/victory-core/src/config.rs → exit 1 (test absent on base).
  • git diff --check 0cef07e9 HEAD clean; diff 2 files, +48/−1.

No full workspace suite or clippy locally. GPU/driver N/A (CPU-only config validation). AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.

**@⁠cloph-dsp** on GitHub · 2026-11-27 23:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/224#issuecomment-7230436499) Independent local verification of PR #224 (refuse a `data_dir` equal to or inside the `cache_dir`). - Windows, Rust 1.100.0/MSVC (Scoop rust-msvc, no rustup/clippy), `cargo test --locked`, synthetic inputs only. - Head `0f52dbd892f2e9af7a84e0edc9bec635ec42dc32`, merge base `0cef07e9d766df48f0e95f13ce3bbbe2290fe9d3`, worktree-local `CARGO_TARGET_DIR`. - Commands: - `cargo test --locked -p victory-core --lib -- config::tests::data_dir_inside_cache_dir_is_refused --exact --test-threads=1 --quiet` → `test result: ok. 1 passed; 0 failed; 15 filtered out`, exit 0. - `cargo test --locked -p victory-core --lib -- config::tests --quiet` → `test result: ok. 11 passed; 0 failed; 5 filtered out`, exit 0 (includes the sibling tests `data_dir_equal_to_cache_dir_is_refused` and `sibling_with_similar_prefix_and_cache_inside_data_are_allowed`). - Negative control: `git grep -F data_dir_inside_cache_dir_is_refused 0cef07e9 -- crates/victory-core/src/config.rs` → exit 1 (test absent on base). - `git diff --check 0cef07e9 HEAD` clean; diff 2 files, +48/−1. No full workspace suite or clippy locally. GPU/driver N/A (CPU-only config validation). AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
The changes on this branch are already on the target branch. This will be an empty commit.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/224/head:github-bot/gh-224'
git switch 'github-bot/gh-224'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-224'
git switch 'github-bot/gh-224'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-224'
git switch 'github-bot/gh-224'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-224'
git switch 'main'
git merge --squash 'github-bot/gh-224'
git switch 'main'
git merge --ff-only 'github-bot/gh-224'
git switch 'main'
git merge 'github-bot/gh-224'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.