Repository navigation
policy: resolve a .. in the not-yet-existing part of a path - #937
Conversation
`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 such as `<tmp>/a/../b` (nothing exists yet) hit the `_` arm and returned PolicyError::Io, so a cache_dir or data_dir with a `..` in 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. Test: resolves_dot_dot_in_a_path_that_does_not_exist_yet (fails before, passes after). cargo test -p victory-core, cargo fmt --check and cargo clippy --tests are clean.
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):
cargo test -p victory-core: 12 passed, 0 failedcargo clippy -p victory-core --all-targets: 0 warningscargo xtask policy: ok
Clean security/policy fix resolving .. components in not-yet-existing path tails. Approving.
AI-assisted (Gemini 4 Neon).
|
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. One more than the baseline; resolving 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 |
|
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 We'd appreciate community testing and feedback on PR #973 as well to assist maintainers with landing the fix! |
Merges Marvisak#188 Marvisak#213 Marvisak#214 Marvisak#219 Marvisak#221 Marvisak#311 Marvisak#324 Marvisak#363 Marvisak#406 Marvisak#454 Marvisak#529 Marvisak#560 Marvisak#708 Marvisak#937 Marvisak#941 Marvisak#963 Marvisak#1111 Marvisak#1159 Marvisak#1304 Marvisak#1306 onto main (ffe310e), each head unchanged, no conflicts. One change of mine: the long-format import descriptor code Marvisak#963 adds nests `if size == 0` in an `if let`, which clippy::collapsible_if rejects under -D warnings; it is now one `if let ... && size == 0` (clippy --fix, no change of behaviour). cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (388 passed, 7 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
What changed
resolvecanonicalizes the longest existing prefix and re-appends the rest, but it walks up withPath::file_name(), which isNonefor a trailing... A path like<tmp>/a/../bwhere nothing exists yet reached the_arm and returnedPolicyError::Io. So acache_dirordata_dircontaining a..under a directory that does not exist yet was rejected, andnormalize's..handling for the missing tail was never reached.A trailing
..is now kept inrest, sonormalizeresolves it lexically as its doc comment says.Test
resolves_dot_dot_in_a_path_that_does_not_exist_yetfails on main (theexpectonresolve) and passes with the change.cargo test -p victory-core: 12 passed.cargo fmt --checkandcargo clippy -p victory-core --testsclean. 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.