Skip to content

fix(links): resolve paths inside the root and report non-portable destinations - #110

Merged
drevendev merged 1 commit into
masterfrom
beautifulrepo/link-path-boundaries-20261023
Oct 23, 2026
Merged

drevendev merged 1 commit into
masterfrom
beautifulrepo/link-path-boundaries-20261023

Conversation

@drevendev

Copy link
Copy Markdown
Owner

Reader problem and change

The link checkers resolved paths with Path.resolve() and listed Markdown files with os.walk. Both follow symbolic links, and os.walk also follows NTFS junctions, all before the containment check runs. As a result:

  • a junction loop could hang docs_links.py and html_navigation.py;
  • on Windows, a destination such as docs\guide.md or %43:/x was read as a Windows path, not the repository-relative path GitHub sees.

The change:

  • Non-portable destinations. A destination containing a backslash or a drive prefix, also when percent-encoded, is reported as non-portable destination (backslash or drive letter) before any filesystem call.
  • Root-bounded resolution. Sources and destinations are resolved step by step inside the root. Each entry is lstat-ed. A symbolic link or junction target is read and checked as text (link_target_parts) before it is followed. Targets outside the root are reported as escapes repository root, as before, and a cycle is reported after 40 hops.
  • File listing. Markdown files are listed without following links or junctions.
  • tools/README.md and the changelog describe the behaviour.

Part of #108. The repo_audit.py half of that issue is still open.

Evidence

  • Results on BeautifulRepo itself are unchanged: 194 Markdown destinations and 205 HTML/fragment destinations across 46 files.
  • Existing symlink contracts still hold: a dangling source gives "cannot resolve", an external source gives "escapes repository root" without reading it, and ../outside.md gives "escapes".

Verification

  • The five local checks passed on Windows 11 with Python 3.14.7 and 3.13.15: catalog OK; docs links 194; HTML navigation 205; 262 tests OK, 7 skipped; repo audit 0 findings.
  • New tests/test_path_boundaries.py:
    • backslash, drive and device destinations are rejected without any os.lstat/os.readlink call;
    • Windows and POSIX link targets are classified from their text;
    • junction loops finish;
    • junctions inside the root are followed, junctions out of it are reported unread;
    • a symlink cycle is a diagnostic.
  • Locally skipped, so this PR's CI is their first run: the symlink tests need a privilege this machine lacks; Linux and Python 3.11 aren't installed here.
  • Accessibility and visual checks: not applicable.

Limitations

🤖 Generated with Claude Code

…tinations

docs_links.py and html_navigation.py resolved sources and destinations with
Path.resolve() and listed Markdown files with os.walk. Both follow symbolic
links, and os.walk follows NTFS junctions, before the containment check runs.
A junction loop could hang the scan, and on Windows a destination written with
backslashes or a drive letter was read as a Windows path instead of the
repository-relative path GitHub sees.

- Report destinations containing a backslash or a drive prefix, also when
  percent-encoded, as non-portable before touching the filesystem.
- Resolve sources and destinations step by step inside the root: each entry is
  lstat-ed, and a symbolic link or junction target is read and checked before
  it is followed. A cycle is reported after 40 hops.
- List Markdown files without following links or junctions.

Part of #108.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@andy-zen-dev andy-zen-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 3d5b0175771daf3d6a6dc24cc33d90518335b389 against issue #108 and the repository's contribution rules. The patch changes the two link scanners to enumerate Markdown entries with lstat (without following directory junctions), resolve source/destination components inside the repository, classify external link targets before following them, and reject non-portable backslash/drive destinations. I inspected tools/docs_links.py, its html_navigation.py integration, the added POSIX/Windows boundary tests and the documentation. No merge-blocking regression found within this scope.

Quality checks run 39916796478 is green in all five required jobs, including Windows Python 3.14 and the two Action self-tests. I did not run an additional local test suite. The PR correctly identifies the outstanding repo_audit.py half of #108 and the macOS/Windows-path limitations; approval is for this partial, bounded link-checker change, not confirmation that all of #108 is complete.

@drevendev
drevendev merged commit 8e6c99e into master Oct 23, 2026
5 checks passed
@drevendev
drevendev deleted the beautifulrepo/link-path-boundaries-20261023 branch October 23, 2026 07:30
drevendev added a commit that referenced this pull request Oct 23, 2026
Combine #97's privacy disclosure changes with the independently
integrated #109 Action fixes and #110 link-safety corrections.
Preserve both histories without force-pushing.
drevendev added a commit that referenced this pull request Oct 23, 2026
…ymlinks

repo_audit.py checked only Path.is_symlink(), which is False for an NTFS
junction. A junction named docs or .github was therefore listed and its
documents were read from wherever it pointed, contrary to the documented
"directory symlinks are not traversed" guarantee. Both the inventory and the
document reader now use lstat and the junction reparse tag, so a junction is
reported as path.symlink and never read through.

The link-checker half of #108 landed with #110.

Closes #108

Co-Authored-By: Claude Opus 5.5 <[email protected]>
drevendev added a commit that referenced this pull request Oct 23, 2026
…ymlinks (#111)

repo_audit.py checked only Path.is_symlink(), which is False for an NTFS
junction. A junction named docs or .github was therefore listed and its
documents were read from wherever it pointed, contrary to the documented
"directory symlinks are not traversed" guarantee. Both the inventory and the
document reader now use lstat and the junction reparse tag, so a junction is
reported as path.symlink and never read through.

The link-checker half of #108 landed with #110.

Closes #108

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants