policy: resolve a .. in the not-yet-existing part of a path #937

Merged
nino-exe merged 1 commit from upstream-pr/937 into main 2026-11-25 00:17:01 +00:00
nino-exe commented 2026-11-24 14:20:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nino-exe on 2026-11-24T14:20:57Z.


What changed

resolve canonicalizes the longest existing prefix and re-appends the rest, but it walks up with Path::file_name(), which is None for a trailing ... A path like <tmp>/a/../b where nothing exists yet reached the _ arm and returned PolicyError::Io. So a cache_dir or data_dir containing a .. under a directory that does not exist yet was rejected, and normalize's .. handling for the missing tail was never reached.

A trailing .. is now kept in rest, so normalize resolves it lexically as its doc comment says.

Test

resolves_dot_dot_in_a_path_that_does_not_exist_yet fails on main (the expect on resolve) and passes with the change. cargo test -p victory-core: 12 passed. cargo fmt --check and cargo clippy -p victory-core --tests clean. Windows 11, Rust 1.98.1 (MSVC). No game data used.

Related but distinct: #310 changes the same function for the AppContainer canonicalize failure; this is about .. in a missing tail.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6583896904 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/937). Originally posted by [nino-exe](https://github.com/nino-exe) on 2026-11-24T14:20:57Z. --- ### What changed `resolve` canonicalizes the longest existing prefix and re-appends the rest, but it walks up with `Path::file_name()`, which is `None` for a trailing `..`. A path like `<tmp>/a/../b` where nothing exists yet reached the `_` arm and returned `PolicyError::Io`. So a `cache_dir` or `data_dir` containing a `..` under a directory that does not exist yet was rejected, and `normalize`'s `..` handling for the missing tail was never reached. A trailing `..` is now kept in `rest`, so `normalize` resolves it lexically as its doc comment says. ### Test `resolves_dot_dot_in_a_path_that_does_not_exist_yet` fails on main (the `expect` on `resolve`) and passes with the change. `cargo test -p victory-core`: 12 passed. `cargo fmt --check` and `cargo clippy -p victory-core --tests` clean. Windows 11, Rust 1.98.1 (MSVC). No game data used. Related but distinct: #310 changes the same function for the AppContainer canonicalize failure; this is about `..` in a missing tail.
DenRakEiw commented 2026-11-24 15:03:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:24:08Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-core: 12 passed, 0 failed
  • cargo clippy -p victory-core --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean security/policy fix resolving .. components in not-yet-existing path tails. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040965652 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/937#pullrequestreview-6040965652). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:24:08Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-core`: **12 passed, 0 failed** - `cargo clippy -p victory-core --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean security/policy fix resolving `..` components in not-yet-existing path tails. Approving. AI-assisted (Gemini 4 Neon).
dcastell1 commented 2026-11-24 15:04:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T14:35:07Z.


Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

cargo test --workspace
343 passed; 0 failed; 6 ignored   (exit 0)

One more than the baseline; resolving .. in the not-yet-existing part of a path is exercised and green.

Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran cargo test --workspace, reverted it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134615860 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/937#issuecomment-7134615860). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T14:35:07Z. --- Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` cargo test --workspace 343 passed; 0 failed; 6 ignored (exit 0) ``` One more than the baseline; resolving `..` in the not-yet-existing part of a path is exercised and green. Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran `cargo test --workspace`, reverted it.
pushkarreddyy commented 2026-11-24 15:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T14:43:52Z.


Thanks @nino-exe for working on this and @dcastell1 for testing!

Heads-up that Issue #793 was claimed earlier (claim on #793) with our PR open at #973. It addresses both trailing .. when file_name() is None and Windows \\?\ verbatim prefixes, clean under clippy warnings and already verified downstream in PR #14.

We'd appreciate community testing and feedback on PR #973 as well to assist maintainers with landing the fix!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134854830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/937#issuecomment-7134854830). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-24T14:43:52Z. --- Thanks @nino-exe for working on this and @dcastell1 for testing! Heads-up that Issue #793 was claimed earlier ([claim on #793](https://github.com/Marvisak/VIctory/issues/793#issuecomment-7131084065)) with our PR open at #973. It addresses both trailing `..` when `file_name()` is `None` and Windows `\\?\` verbatim prefixes, clean under clippy warnings and already verified downstream in PR #14. We'd appreciate community testing and feedback on PR #973 as well to assist maintainers with landing the fix!
Zipettte commented 2026-11-24 16:05:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:48Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 52f0a09: cargo test -p victory-core passes, 12 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136431256 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/937#issuecomment-7136431256). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:48Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 52f0a09: `cargo test -p victory-core` passes, 12 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
upstream-sync closed this pull request 2026-11-25 01:04:57 +00:00
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!937
No description provided.