Skip to content

fix(oas:sync): refuse symlinks so sync cannot write outside reference/ - #60

Merged
erunion merged 7 commits into
mainfrom
fix/oas-sync-containment
Nov 3, 2026
Merged

erunion merged 7 commits into
mainfrom
fix/oas-sync-containment

Conversation

@erunion

@erunion erunion commented Nov 3, 2026

Copy link
Copy Markdown
Member

Summary

  • oas:sync treated containment as a string comparison, so a directory symlink committed at reference/<info.title> (git mode 120000) passed the check and the following mkdir, writeFile, rename, unlink, and rm calls followed it out of the repo. Sync now refuses any symlink under reference/ before it modifies the tree, and every write or delete resolves the real path and rejects a symlink segment. The command prints the refused path and exits non-zero. lint --fix reports that refusal instead of marking the sync fixed.
  • The same lexical check in pretty and the import staging guard now uses the same helper.
  • Fixes CX-4160.

Test plan

  • npx vitest run (275 tests)
  • Symlink at reference/<title> pointing outside the repo: sync throws, the outside directory is unchanged, and an in-repo stale page is not deleted first
  • Symlink whose target is also inside reference/, a tag-folder symlink, and a symlinked page are refused
  • oas:sync prints the refusal and exits 1
  • lint --fix reports the refusal and does not mark the missing page fixed
  • Confirm a normal docs repo with no symlinks under reference/ still syncs

Made with Cursor

A directory symlink committed under reference/ passes the lexical containment check and the following mkdir, write, rename, unlink, and rm calls follow it. Resolve each destination and stop before anything is modified.

Co-authored-by: Cursor <cursoragent@cursor.com>
@erunion erunion added the bug Something isn't working label Nov 3, 2026
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issue was found.

Reviews (3) · Last reviewed commit: "fix(oas:sync): read order files through ..." · Reviewed by Greptile

Comment thread src/commands/oas-sync.js Resolved
erunion and others added 5 commits November 3, 2026 15:00
findOasFiles skips symlink specs, so a reference directory whose only spec is a link returned success and left pages unsynced. Check for symlinks first and exit non-zero.

Co-authored-by: Cursor <cursoragent@cursor.com>
The order helpers, folder listing, and tag cleanup each reimplemented the symlink refusal. One read path now lstats, asserts, then reads, and the unrelated jiti and yaml lockfile entries are restored.

Co-authored-by: Cursor <cursoragent@cursor.com>
@erunion
erunion merged commit e32099a into main Nov 3, 2026
5 checks passed
@erunion
erunion deleted the fix/oas-sync-containment branch November 3, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant