Repository navigation
fix(oas:sync): refuse symlinks so sync cannot write outside reference/ - #60
Merged
Merged
Conversation
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>
Contributor
[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 |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
oas:synctreated containment as a string comparison, so a directory symlink committed atreference/<info.title>(git mode 120000) passed the check and the followingmkdir,writeFile,rename,unlink, andrmcalls followed it out of the repo. Sync now refuses any symlink underreference/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 --fixreports that refusal instead of marking the sync fixed.prettyand the import staging guard now uses the same helper.Test plan
npx vitest run(275 tests)reference/<title>pointing outside the repo: sync throws, the outside directory is unchanged, and an in-repo stale page is not deleted firstreference/, a tag-folder symlink, and a symlinked page are refusedoas:syncprints the refusal and exits 1lint --fixreports the refusal and does not mark the missing page fixedreference/still syncsMade with Cursor