Resolve Symlinks Before Accepting a Canonical File - #979
Conversation
CodeRabbit finding on the develop -> main promotion PR (#978), against PR #977's earlier is_file() checks: a tracked in-repo symlink whose target escapes ROOT would pass both escapes_repo_root() (a lexical string check) and a bare Path.is_file() (which follows the link) the same way a real file would. The audit engine would then read that external target's live filesystem content while dating it from the symlink's own git history, a mismatch between what was verified and what was read. Add canonical_file_in_root(), which resolves the candidate strictly and requires the result to both exist as a file and stay under ROOT, and use it in place of the two is_file() calls PR #977 added. Verified by hand: symlinked a path inside this checkout to a file outside it, confirmed the new check rejects it while still accepting a real hub file and still rejecting a missing path and a directory, removed the symlink after.
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds canonical, symlink-aware path validation. Intent references must resolve to existing files within the repository root. ChangesIntent reference validation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk:⚪ Minimal · up to The change tightens canonical-file validation for symlinks without introducing an identified merge-blocking issue; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoResolve symlinks before accepting canonical file paths in validation
AI Description
Diagram
High-Level Assessment
Files changed (1) |
Code Review by Qodo
1. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
CodeRabbit finding on the develop -> main promotion PR (#978), against
spec/validate.py's newis_file()checks from PR #977: a trackedin-repo symlink whose target escapes
ROOTpasses bothescapes_repo_root()(a lexical string check) and a barePath.is_file()(which follows the link) the same way a real filewould. The audit engine would then read that external target's live
filesystem content while dating it from the symlink's own git history.
Add
canonical_file_in_root(), which resolves the candidate strictlyand requires the result to both exist as a file and stay under
ROOT,in place of the two
is_file()calls.Verified by hand: symlinked a path inside this checkout to a file
outside it, confirmed the new check rejects it while still accepting
a real hub file and still rejecting a missing path and a directory,
removed the symlink after.
--selftest,ruff,mypy,prose_lint.py,repo_gate.py, and thescripts/tests/pytest suite(838 passed) all clean.
Summary by CodeRabbit
referenceandintentRefvalidation for more accurate and reliable results.