HLE: avoid following links during storage quota scans #1506

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

@⁠Calvix2k on GitHub · 2026-11-24 18:35 UTC · original
Calvix2k:codex/storage-ignore-links-040 → main · +43 −11 · 1 files · 1 commits · closed without merging

Summary

Fixes VIC-BT-040 from audit issue #1249.

used_bytes previously called DirEntry::metadata(), which follows directory symlinks and junctions. A link back into the tree could recurse indefinitely, and an external link could make the title's quota scan count data outside its storage directory.

The scan now uses an explicit pending-directory stack, checks entry types without following links, skips symlinks, and counts regular files. A regression test creates a nested self-referential directory link and verifies the scan terminates while still counting nested file contents.

Verification

  • cargo test -p victory-hle --lib --locked (95 passed)
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings
  • rustfmt --check --edition 2024 crates/victory-hle/src/modules/storage.rs
  • cargo xtask policy --staged
  • git diff --check

Tested on Windows 10. The regression test successfully created the directory symlink in this environment; no game data was used.

**@⁠Calvix2k** on GitHub · 2026-11-24 18:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1506) `Calvix2k:codex/storage-ignore-links-040` → `main` · +43 −11 · 1 files · 1 commits · closed without merging ## Summary Fixes `VIC-BT-040` from audit issue #1249. `used_bytes` previously called `DirEntry::metadata()`, which follows directory symlinks and junctions. A link back into the tree could recurse indefinitely, and an external link could make the title's quota scan count data outside its storage directory. The scan now uses an explicit pending-directory stack, checks entry types without following links, skips symlinks, and counts regular files. A regression test creates a nested self-referential directory link and verifies the scan terminates while still counting nested file contents. ## Verification - `cargo test -p victory-hle --lib --locked` (95 passed) - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings` - `rustfmt --check --edition 2024 crates/victory-hle/src/modules/storage.rs` - `cargo xtask policy --staged` - `git diff --check` Tested on Windows 10. The regression test successfully created the directory symlink in this environment; no game data was used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:24 +00:00
github-bot closed this pull request 2026-11-26 04:34:24 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 22:32 UTC · original

Tested on Windows 11 with the repo toolchain, merged into current main (70564ae):

cargo test -p victory-hle passed failed ignored
main 99 0 0
main + this PR 100 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

**@⁠acetonahard-code** on GitHub · 2026-11-24 22:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1506#issuecomment-7146350673) Tested on Windows 11 with the repo toolchain, merged into current `main` (70564ae): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 99 | 0 | 0 | | `main` + this PR | 100 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:41 UTC · original

Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1506#issuecomment-7148781643) Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 00:52 UTC · original

Before I rework this: could you say which case the triage considered incorrect? I see two candidates and would fix the right one rather than guess:

  • Windows junctions/mount points. FileType::is_symlink() does not necessarily catch a junction, so is_dir() would still push it and the loop follows it — the PR would not actually close the hole it targets. I can switch to symlink_metadata and skip every FILE_ATTRIBUTE_REPARSE_POINT directory instead.
  • File links. The PR also stops counting a symlinked file, which would under-count a tree that legitimately links saves. I can keep following file links (counting their target size) and only refuse directory links.

If the intended semantic is "count the title's own files, never traverse out of the storage root", I can implement exactly that with reparse-point detection and a test for a junction as well as a symlink. No reopen until that is agreed.

**@⁠Calvix2k** on GitHub · 2026-11-25 00:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1506#issuecomment-7148972684) Before I rework this: could you say which case the triage considered incorrect? I see two candidates and would fix the right one rather than guess: - **Windows junctions/mount points.** FileType::is_symlink() does not necessarily catch a junction, so is_dir() would still push it and the loop follows it — the PR would not actually close the hole it targets. I can switch to symlink_metadata and skip every FILE_ATTRIBUTE_REPARSE_POINT directory instead. - **File links.** The PR also stops counting a symlinked *file*, which would under-count a tree that legitimately links saves. I can keep following file links (counting their target size) and only refuse directory links. If the intended semantic is "count the title's own files, never traverse out of the storage root", I can implement exactly that with reparse-point detection and a test for a junction as well as a symlink. No reopen until that is agreed.

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!1506
No description provided.