Skip to content

Keep tools inside the workspace through symlinks - #15

Open
stephankaag wants to merge 1 commit into
crmne:mainfrom
stephankaag:symlink-pr
Open

stephankaag wants to merge 1 commit into
crmne:mainfrom
stephankaag:symlink-pr

Conversation

@stephankaag

Copy link
Copy Markdown

Workspace#resolve compares a path's spelling with the root. A symlink inside the workspace that leads outside it lets read and list reach whatever it points at, and write create files there. A cloned repository can bring such a link, and code run in the workspace can make one with ln -s ~/.ssh keys.

Now a path is judged by where it really leads: the part that exists, with its links resolved, then the rest, which a write would create, against the root as the file system knows it (on macOS /var is /private/var). A broken link on the way is refused, since a write would follow it anywhere. Links that stay inside keep working.

workspace = RubyLLM::Code::Workspace.new(dir)
File.symlink(Dir.home, File.join(dir, "home"))

workspace.resolve("home/.ssh/id_ed25519")
# before: "#{dir}/home/.ssh/id_ed25519", which read opens as ~/.ssh/id_ed25519
# now:    RubyLLM::Code::ToolError: home/.ssh/id_ed25519 is outside the workspace

Specs cover a file and a new file through a link that leads out, the link itself, a broken link, links that stay inside, globs leaving outside links out, new files in folders that do not exist yet, and a root reached through a link.

Workspace#resolve compared a path's spelling with the root, so a symlink
inside the workspace that led outside let read and list reach whatever
it pointed at, and write create files there. A cloned repository can
bring such a link, and code run in the workspace can make one.

A path is now judged by where it really leads: the part that exists with
its links resolved, then the rest, which a write would create, against
the root as the file system knows it. A broken link on the way is
refused, since a write would follow it anywhere. Links that stay inside
keep working.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants