Skip to content

fix(lint): refuse symlinks so --fix cannot write outside the repo - #67

Merged
erunion merged 3 commits into
mainfrom
fix/lint-symlinks
Nov 11, 2026
Merged

erunion merged 3 commits into
mainfrom
fix/lint-symlinks

Conversation

@erunion

@erunion erunion commented Nov 11, 2026

Copy link
Copy Markdown
Member

Summary

readme lint --fix followed committed symlinks and wrote the file they pointed at. A symlinked _order.yaml could gain - <slug> lines or lose existing - lines, and a symlinked page could have unknown frontmatter keys renamed to x-<key>. A symlinked docs/ directory was the same hole one level up.

The ordering walk now refuses a symlink before it reads the directory or the order file, and it does not queue a fix for that path. collectFiles does not list a linked content root, so that directory is one ordering error rather than one error per child. With --fix, each page is checked once at open; a symlinked page is reported and skipped, so frontmatter never rewrites it. PathEscapeError names the path under the base the caller passed, so path.relative stays inside the repo when that base is reached through a symlink such as /var → /private/var.

Fixes RM-19517.

Test plan

  • npx vitest run test/security/lint-fix-symlink.test.js test/utils/containment.test.js test/validators/ordering.test.js test/validators/frontmatter.test.js test/validators/oas-reference.test.js
  • Symlinked _order.yaml: --fix appends nothing and does not delete existing - lines. The target file is unchanged and the link is still a symlink.
  • Symlinked docs/: one ordering error, and files inside the target are not rewritten.
  • Symlinked page with an unknown frontmatter key: the target still has that key, not x-<key>.
  • A real page with an unknown key is still rewritten to x-<key>.

Made with Cursor

A committed symlink under docs/ was followed by lint --fix, so an order file or page rewrite could modify a file outside the repository.

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

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Reviews (3) · Last reviewed commit: "fix: rebuild the gha dist" · Reviewed by Greptile

Comment thread src/utils/lint.js Resolved
Comment thread src/utils/lint.js Resolved
…hecks

A dangling page symlink was still handed to links, which threw ENOENT, and a linked custom_blocks/ directory was skipped with no error.

Co-authored-by: Cursor <cursoragent@cursor.com>
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 11, 2026 00:30

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@erunion
erunion merged commit 0a415ea into main Nov 11, 2026
5 checks passed
@erunion
erunion deleted the fix/lint-symlinks branch November 11, 2026 00:34
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