Repository navigation
feat(sandbox): add read-only Go lib carve-out - #1022
Merged
Merged
Conversation
Add isWithinGoLibDirs function that resolves GOMODCACHE and GOROOT/src from the environment at runtime, and include it in the ValidatePathInSandbox carve-out so read tools can access Go library sources by default. Add ValidatePathInSandboxWrite method that rejects paths under Go lib directories, and update Edit/Delete/MultiEdit tools and the filewriter validator to call it instead of ValidatePathInSandbox, keeping the carve-out read-only.
4 tasks
edenreich
reviewed
Aug 4, 2026
edenreich
reviewed
Aug 4, 2026
Co-authored-by: Eden Reich <[email protected]>
edenreich
marked this pull request as ready for review
August 4, 2026 20:18
Relative paths bypassed ValidatePathInSandboxWrite's prefix match against the absolute GOMODCACHE/GOROOT dirs, allowing writes into the read-only carve-out. Resolve to an absolute path first and add a regression test.
Contributor
|
🎉 This PR is included in version 0.161.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Resolves #1020
Summary
Add a read-only sandbox carve-out for Go library directories (GOMODCACHE and GOROOT/src) so the Read tool can access dependency sources by default without manual config. The carve-out is read-only: Write/Edit/Delete tools reject mutations under these paths.
Changes
isWithinGoLibDirsfunction inconfig/config.gothat resolves GOMODCACHE (from $GOMODCACHE, $GOPATH/pkg/mod, or ~/go/pkg/mod) and GOROOT/src (from $GOROOT) at runtime from the environmentisWithinGoLibDirsin theValidatePathInSandboxcarve-out so read tools (Read, Grep, Tree) can access Go library sources by defaultValidatePathInSandboxWritemethod that rejects paths under Go lib directories, keeping the carve-out read-onlyValidatePathInSandboxWriteinstead ofValidatePathInSandbox*.env,.git/) still apply inside Go lib directoriestools.sandbox.directoriesas before