Policy: a path with .. below a directory not yet created resolves #252

Closed
github-bot wants to merge 1 commit from gh-pr/252/head into gh-pr/252/base
Owner

@⁠SkippySteve on GitHub · 2026-11-24 01:50 UTC · original
SkippySteve/policy-dotdot-missing → main · +23 −3 · 1 files · 1 commits · closed without merging

ensure_outside_repo resolves a destination that does not exist yet by walking up to its longest existing prefix, canonicalizing that, and re-appending the rest. The walk takes each component with Path::file_name, which is None for a path ending in ... So a destination with .. below a directory that is not created yet, such as <tmp>/missing/../cache, fails with

cannot resolve /tmp/.tmpXXXX/missing/../cache: No such file or directory (os error 2)

instead of being checked. A cache or data directory configured that way is refused even though it is outside the repository (Cache::open, the config's subdir, and victory config report it as an error).

The fix takes the last component with components().next_back() and accepts both normal names and ..; the tail is already normalized lexically afterwards, so missing/../cache becomes cache under the canonical prefix. Root and prefix components still end the walk with the same error as before.

The new test resolves_dotdot_after_a_missing_directory checks that <tmp>/missing/../cache is accepted and that <repo>/not-yet-created/../out is reported as InsideRepo (it was an Io error before). It fails on main and passes with the fix.

cargo test -p victory-core and cargo clippy -p victory-core --all-targets pass (on Linux). config.rs is not touched.

**@⁠SkippySteve** on GitHub · 2026-11-24 01:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/252) `SkippySteve/policy-dotdot-missing` → `main` · +23 −3 · 1 files · 1 commits · closed without merging `ensure_outside_repo` resolves a destination that does not exist yet by walking up to its longest existing prefix, canonicalizing that, and re-appending the rest. The walk takes each component with `Path::file_name`, which is `None` for a path ending in `..`. So a destination with `..` below a directory that is not created yet, such as `<tmp>/missing/../cache`, fails with ``` cannot resolve /tmp/.tmpXXXX/missing/../cache: No such file or directory (os error 2) ``` instead of being checked. A cache or data directory configured that way is refused even though it is outside the repository (`Cache::open`, the config's `subdir`, and `victory config` report it as an error). The fix takes the last component with `components().next_back()` and accepts both normal names and `..`; the tail is already normalized lexically afterwards, so `missing/../cache` becomes `cache` under the canonical prefix. Root and prefix components still end the walk with the same error as before. The new test `resolves_dotdot_after_a_missing_directory` checks that `<tmp>/missing/../cache` is accepted and that `<repo>/not-yet-created/../out` is reported as `InsideRepo` (it was an `Io` error before). It fails on `main` and passes with the fix. `cargo test -p victory-core` and `cargo clippy -p victory-core --all-targets` pass (on Linux). `config.rs` is not touched.
ensure_outside_repo walks up to the longest existing prefix by file_name,
which is None for a path ending in `..`. A destination such as
<tmp>/missing/../cache therefore failed with "cannot resolve ... No such
file or directory" instead of being checked, so a cache or data directory
configured that way was refused even outside the repository. Keep the last
component (normal or `..`) and let the existing lexical normalization of
the tail resolve it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:44 +00:00
github-bot closed this pull request 2026-11-26 03:56:44 +00:00
Author
Owner

@⁠SkippySteve on GitHub · 2026-11-24 02:28 UTC · original

Superseded by #246, which now includes this change (rebased onto main, with its test).

**@⁠SkippySteve** on GitHub · 2026-11-24 02:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/252#issuecomment-7120175051) Superseded by #246, which now includes this change (rebased onto main, with its test).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!252
No description provided.