Skip to content

feat(sandbox): add read-only Go lib carve-out - #1022

Merged
edenreich merged 3 commits into
mainfrom
fix/issue-1020
Aug 4, 2026
Merged

edenreich merged 3 commits into
mainfrom
fix/issue-1020

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

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

  • Add isWithinGoLibDirs function in config/config.go that resolves GOMODCACHE (from $GOMODCACHE, $GOPATH/pkg/mod, or ~/go/pkg/mod) and GOROOT/src (from $GOROOT) at runtime from the environment
  • Include isWithinGoLibDirs in the ValidatePathInSandbox carve-out so read tools (Read, Grep, Tree) can access Go library sources by default
  • Add ValidatePathInSandboxWrite method that rejects paths under Go lib directories, keeping the carve-out read-only
  • Update Edit, Delete, MultiEdit tools and the filewriter validator to call ValidatePathInSandboxWrite instead of ValidatePathInSandbox
  • Protected-path rules (e.g. *.env, .git/) still apply inside Go lib directories
  • Users can still extend tools.sandbox.directories as before

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.
Comment thread config/config.go Resolved
Comment thread config/config.go Resolved
@edenreich
edenreich marked this pull request as ready for review August 4, 2026 20:18
@edenreich
edenreich requested a review from a team as a code owner 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.
@edenreich
edenreich merged commit cfeb455 into main Aug 4, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1020 branch August 4, 2026 20:26
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.161.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Golang or any other global libraries should be accessible by default

1 participant