Skip to content

Extract filesystem sandboxing into pathSandbox#3

Merged
AlexandreYang merged 1 commit intomainfrom
dd/extract-path-sandbox-type
Mar 9, 2026
Merged

Extract filesystem sandboxing into pathSandbox#3
AlexandreYang merged 1 commit intomainfrom
dd/extract-path-sandbox-type

Conversation

@AlexandreYang
Copy link
Copy Markdown
Member

Summary

Replaces the parallel allowedPaths []string / roots []*os.Root slices with a single pathSandbox type that owns both the path strings and their os.Root handles together. This centralizes the security boundary and removes index-coupling between the two slices.

Changes

  • Introduced allowedRoot struct pairing absPath with its *os.Root handle
  • Introduced pathSandbox struct with resolve, open, readDir, openRoots, and Close methods
  • AllowedPaths option now creates a *pathSandbox instead of populating raw slices
  • Replaced Runner.allowedPaths + Runner.roots with a single Runner.sandbox *pathSandbox
  • Updated Reset(), Close(), and subshell() in api.go to use the new type
  • Removed standalone findMatchingRoot, restrictedOpenHandler, and restrictedReadDirHandler functions

Testing

  • All existing AllowedPaths* tests pass (18 tests)
  • Full project test suite passes (go test ./...)

PR by Bits
View session in Datadog

Comment @DataDog to request changes

Co-authored-by: AlexandreYang <49917914+AlexandreYang@users.noreply.github.com>
@datadog-official
Copy link
Copy Markdown
Contributor

View session in Datadog

Bits Dev status: ✅ Done

CI Auto-fix: Disabled | Enable

Comment @DataDog to request changes

@AlexandreYang AlexandreYang merged commit f468a45 into main Mar 9, 2026
4 of 7 checks passed
@AlexandreYang AlexandreYang deleted the dd/extract-path-sandbox-type branch March 9, 2026 09:10
@matt-dz matt-dz mentioned this pull request Mar 11, 2026
5 tasks
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.

2 participants