Skip to content

feat(allowedpaths): skip nonexistent paths instead of failing#164

Merged
matt-dz merged 9 commits intomainfrom
matt-dz/no-fail-on-bad-path
Mar 30, 2026
Merged

feat(allowedpaths): skip nonexistent paths instead of failing#164
matt-dz merged 9 commits intomainfrom
matt-dz/no-fail-on-bad-path

Conversation

@matt-dz
Copy link
Copy Markdown
Collaborator

@matt-dz matt-dz commented Mar 30, 2026

Summary

AllowedPaths is now treated as an allowlist — paths that don't exist at construction time are silently skipped instead of causing New() to fail. The sandbox operates with whatever paths are available.

This supports use cases where paths may not exist yet (e.g., config files created after sandbox construction by the agent).

Changes

  • New() uses continue instead of return error when os.OpenRoot fails
  • Switched from pre-allocated indexed slice to append-based accumulation
  • Removed closeAll cleanup (no mid-construction failures)

Tests

  • TestNewSkipsNonexistentPaths — existing dir + nonexistent path, existing dir works
  • TestNewAllPathsNonexistent — all paths missing, sandbox succeeds but blocks all access
  • TestNewEmptyPaths — empty list, blocks all access
  • TestNewMixedExistingAndNonexistent — 3 paths (existing, missing, existing), both existing work
  • YAML scenario: nonexistent path skipped alongside existing dir
  • Updated existing interp tests for new behavior

Test plan

  • go test ./allowedpaths/... passes
  • go test ./interp/... passes
  • go test ./tests/ -run TestShellScenarios passes
  • CI passes

🤖 Generated with Claude Code

@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c152bfe631

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread allowedpaths/sandbox.go
Comment thread tests/scenarios/shell/allowed_paths/nonexistent_path_skipped.yaml Outdated
@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review

Comment thread allowedpaths/sandbox.go
Comment thread allowedpaths/sandbox.go
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b23b97053

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread allowedpaths/sandbox.go
@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review. do not request changes that are beyond the scope of this PR and are already existing issues.

AlexandreYang
AlexandreYang previously approved these changes Mar 30, 2026
Comment thread allowedpaths/sandbox.go
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b23b97053

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread allowedpaths/sandbox.go
Comment thread allowedpaths/sandbox.go
Comment thread allowedpaths/sandbox.go
@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review. do not request changes that are beyond the scope of this PR and are already existing issues.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8a62a429a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread allowedpaths/sandbox.go Outdated
matt-dz and others added 6 commits March 30, 2026 10:24
AllowedPaths is an allowlist — paths that don't exist at construction
time are silently skipped. The sandbox operates with whatever paths
are available.

Tests:
- TestNewSkipsNonexistentPaths: existing dir + nonexistent path
- TestNewAllPathsNonexistent: all paths missing, empty sandbox
- TestNewEmptyPaths: empty list, blocks all access
- TestNewMixedExistingAndNonexistent: 3 paths, middle one missing
- YAML scenario: nonexistent path skipped, existing dir works

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Success-path scenario (cat on existing file) produces identical
output in both rshell and bash — no skip needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
AllowedPaths are suggestions — if we can't open a path for any reason
(missing, not a directory, no permission, etc.), skip it and work with
whatever paths are available.

Also use |+ block scalars in scenario YAML per AGENTS.md convention.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Write a warning to os.Stderr when a path cannot be opened, so
operators can see which paths were dropped. Temporary approach
until a proper logging mechanism is added.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Needed for the stderr warning when skipping unavailable paths in New().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New() now accepts an io.Writer for warnings instead of writing to
os.Stderr directly. The AllowedPaths RunnerOption passes r.stderr
when available, falling back to os.Stderr if not yet configured.

This respects the runner's I/O isolation — warnings go to the
configured stderr stream, not the process-global one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt-dz matt-dz force-pushed the matt-dz/no-fail-on-bad-path branch from 4cb3155 to ad6a970 Compare March 30, 2026 14:24
@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review. do not request changes that are beyond the scope of this PR and are already existing issues.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad6a97070d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread interp/api.go Outdated
Comment thread tests/scenarios/shell/allowed_paths/nonexistent_path_skipped.yaml Outdated
…logic

The test harness filters out non-existent absolute paths via os.Stat
before passing them to interp.AllowedPaths. Switch to a relative path
("nonexistent_dir") which the harness resolves to a temp-dir child
that genuinely doesn't exist, ensuring the skip logic in
allowedpaths.New is actually exercised. Also expect the stderr warning
and mark skip_assert_against_bash since this is rshell-specific.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review. do not request changes that are beyond the scope of this PR and are already existing issues.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85e090213a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread interp/api.go Outdated
matt-dz and others added 2 commits March 30, 2026 10:42
allowedpaths.New no longer accepts an io.Writer for warnings. Instead
it collects diagnostics into a byte buffer and returns them alongside
the sandbox. The AllowedPaths RunnerOption stores the warnings on the
runner, and interp.New flushes them to r.stderr after all options have
been applied and defaults set. This makes warning output independent
of option ordering — callers can pass AllowedPaths before or after
StdIO and warnings always reach the configured stderr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt-dz
Copy link
Copy Markdown
Collaborator Author

matt-dz commented Mar 30, 2026

@codex conduct a comprehensive security and code review. do not request changes that are beyond the scope of this PR and are already existing issues.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@matt-dz matt-dz marked this pull request as ready for review March 30, 2026 14:55
@matt-dz matt-dz added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit 5e83fe1 Mar 30, 2026
34 checks passed
@matt-dz matt-dz deleted the matt-dz/no-fail-on-bad-path branch March 30, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants