Skip to content

Clarify symlink behavior for repository file reads and writes - #3071

Merged
SamMorrowDrums merged 6 commits into
github:mainfrom
theinfosecguy:fix-symlink-file-write-safety
Aug 19, 2026
Merged

Clarify symlink behavior for repository file reads and writes#3071
SamMorrowDrums merged 6 commits into
github:mainfrom
theinfosecguy:fix-symlink-file-write-safety

Conversation

@theinfosecguy

Copy link
Copy Markdown
Contributor

Summary

Clarifies that get_file_contents may follow a symbolic link while repository file writes operate on exact Git paths. Adds guidance for distinguishing updates to linked content from changes to the link itself.

Why

Fixes #2997.

A read can return the linked file's contents, but writing to the same path can rewrite or replace the symbolic link. The existing tool guidance did not explain this difference.

What changed

  • Added repository-level guidance describing the read/write mismatch.
  • Added exact-path behavior to create_or_update_file.path and push_files.files[].path.
  • Added regression coverage for instruction routing and both write behaviors.
  • Updated tool snapshots and generated documentation.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Only descriptions and server instructions changed. Input shapes, handlers, and API call sequences remain unchanged.

Prompts tested (tool changes only)

  • Not applicable. This changes safety guidance rather than runtime behavior. MCP initialization, tools/list output, and the existing handler workflows were verified locally.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

No authentication, permission, data exposure, or resource-limit behavior changed.

Tool renaming

  • I am renaming tools as part of this PR
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Additional validation included tool snapshot tests, repeated race-enabled edge-case tests, and git diff --check.

Docs

  • Not needed
  • Updated (README / docs / examples)

@theinfosecguy
theinfosecguy marked this pull request as ready for review August 14, 2026 15:26
@theinfosecguy
theinfosecguy requested a review from a team as a code owner August 14, 2026 15:26
@SamMorrowDrums
SamMorrowDrums force-pushed the fix-symlink-file-write-safety branch 3 times, most recently from 6822ca7 to a0ec852 Compare August 19, 2026 09:41
theinfosecguy and others added 6 commits August 19, 2026 12:37
Detect existing symlinks through the Git tree and require an explicit opt-in before changing their targets. Return the resolved repository target so callers can safely update the linked file instead.

Refs github#2997

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove persistent repository and push-files guidance in favor of concise runtime recovery content. Resolve refs directly through Git Trees, skip inspection for explicit symlinks and opt-ins, and lock request counts in tests.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Detect internal symlink dereferences from Git blob identity mismatches, disclose explicit links and submodules, and preserve requested-path resource output. Use bounded exact-path tree inspection only when inline content is unavailable.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the lazy blob-identity check and bounded tree fallback while consolidating metadata handling and request-count tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21420b11-5dae-49b6-ac77-965faec7f88b
Report contentless large symlink targets as not returned while preserving their ResourceLink and requested-path identity.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21420b11-5dae-49b6-ac77-965faec7f88b
@SamMorrowDrums
SamMorrowDrums force-pushed the fix-symlink-file-write-safety branch from a0ec852 to d4dcee2 Compare August 19, 2026 10:51
@SamMorrowDrums SamMorrowDrums changed the title Clarify symlink behavior for repository file writes Clarify symlink behavior for repository file reads and writes Aug 19, 2026
@SamMorrowDrums
SamMorrowDrums merged commit a6b8207 into github:main Aug 19, 2026
13 checks passed
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.

Symlink corruption: get_file_contents follows symlinks but create_or_update_file does not

2 participants