core/policy: expand dangling symlinks, reject symlink loops, and handle .. after missing paths #486
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!486
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-486"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@IlyassRS3 on GitHub · 2026-11-25 01:24 UTC · original
IlyassRS3:fix/policy-dangling-symlink-and-dotdot→main· +190 −34 · 1 files · 1 commits · openSummary
Hardens
victory_core::policy::resolve(crates/victory-core/src/policy.rs), which enforces Rule #1 (ensure_outside_repo), to walk components left-to-right and explicitly expand symbolic links (including dangling ones) up to a bounded hop limit (MAX_SYMLINK_HOPS = 40).Bugs fixed
Previously,
resolve()calledstd::fs::canonicalizein a loop and peeled the tail viaPath::file_name()on any error:<outside>/linkis a symlink pointing to<repo>/not-yet-created,canonicalize()fails withNotFound,resolve()peelslinkand returns<outside>/link, andensure_outside_reporeturnsOk(())— allowing caches/outputs to be created inside the repository once the target directory is created.canonicalize()fails withELOOP, which was treated identically toNotFound, peeling the loop component and returningOk(())instead of failing closed...after a non-existent component:Path::file_name()returnsNonefor.., causing valid paths outside the repository like<outside>/missing/..to fail withPolicyError::Io.Implementation notes
RootDirand every existing non-symlink component viastd::fs::canonicalize, and also falls back toread_linkwhencanonicalizefails on a reparse point (such as a dangling NTFS junction) wherefile_type().is_symlink()may be false.#[cfg(unix)]so Windows runners withoutSeCreateSymbolicLinkPrivilegestay green, while running the..regression tests on all platforms.Verification
1.98.1, no Windows GPU / no game files.cargo test --locked -p victory-core -p xtask: 14 passed, 0 failed (victory-core, including 3 new tests:handles_dotdot_after_nonexistent_component,rejects_dangling_symlinks_into_repo,rejects_symlink_loops) + 4 passed, 0 failed (xtask, includingrepository_passes_policy).cargo clippy --locked -p victory-core --all-targets -- -D warnings: 0 warnings.cargo clippy --locked -p victory-core --all-targets --target x86_64-pc-windows-msvc -- -D warningsand--all-features: 0 warnings.upstream/main(a803c87): all 3 new tests fail on unpatchedupstream/main(4 passed; 3 failed).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.