Skip to content

Make sandbox policy configurable with a secure default - #22

Merged
Tyler-R-Kendrick merged 1 commit into
mainfrom
claude/harness-policy-config-gbrytt
Jul 12, 2026
Merged

Make sandbox policy configurable with a secure default#22
Tyler-R-Kendrick merged 1 commit into
mainfrom
claude/harness-policy-config-gbrytt

Conversation

@Tyler-R-Kendrick

@Tyler-R-Kendrick Tyler-R-Kendrick commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

The harness previously forced its own opinionated sandbox policy: consumers could tune a few fields (readonlyPaths, allowedHosts, timeoutMs) but could not supply a policy of their own, and the policy schema version was a hand-maintained constant. This PR keeps the secure default while making the policy fully configurable, and derives the default version from the installed SDK.

Changes

  • HarnessSandboxSettings.policy (new, optional): pass any SandboxPolicy to replace the default. When unset, the sandbox builds the same secure default as before via createSandboxPolicy — writes confined to the workspace, no local network, outbound only with an explicit allowlist, no UI/clipboard/input access.
  • createSandboxPolicy and SandboxPolicySettings are exported from the package index so consumers can build a custom policy by spreading over the default instead of hand-writing a full SandboxPolicy.
  • Removed the hand-maintained policy version constant. The default policy version is now read from the installed @microsoft/mxc-sdk package at runtime; every SDK release accepts its own version in its supported schema range, so the default tracks SDK upgrades automatically. A version override was also added to SandboxPolicySettings.
  • protectedPaths now checks against every writable path in the effective policy (plus the host-side workspace, which uploads write to regardless of policy), not just the workspace — necessary now that custom policies can grant extra writable roots.
  • Updated the harness README and tests to cover the default-policy fallback, consumer-configured policies, and the SDK-derived version default.

Testing

  • npm run typecheck — clean
  • npm test — 84 tests across 15 files pass, including new tests for the default policy fallback, consumer-configured policies, protectedPaths against extra writable roots, and the SDK-derived version default.

🤖 Generated with Claude Code

https://claude.ai/code/session_0136nqkeMmT6DwfMxvhUo5He

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Tyler-R-Kendrick, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f783eac-08e5-4afd-b70e-5a4d0c0142f5

📥 Commits

Reviewing files that changed from the base of the PR and between 80fd149 and c01e58a.

📒 Files selected for processing (5)
  • packages/harness/README.md
  • packages/harness/src/index.ts
  • packages/harness/src/policy.ts
  • packages/harness/src/sandbox.ts
  • packages/harness/test/harness.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/harness-policy-config-gbrytt

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.

MxcSandbox previously ran every policy through assertHarnessPolicy,
rejecting anything that wasn't exactly the harness's opinionated shape,
so consumers could not configure the policy at all. Drop the assertion:
the policy setting is now optional, defaulting to
createHarnessPolicy({ workspace }), and any consumer-supplied
SandboxPolicy is honored as-is.

The protectedPaths guard now checks against every writable path in the
effective policy (plus the host-side workspace), not just the workspace,
so it stays honest under custom policies.

Also remove the hand-maintained sandboxPolicyVersion constant; the
default policy version is read from the installed @microsoft/mxc-sdk
package, which each SDK release accepts, so it tracks upgrades
automatically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136nqkeMmT6DwfMxvhUo5He
@Tyler-R-Kendrick
Tyler-R-Kendrick force-pushed the claude/harness-policy-config-gbrytt branch from 14a119a to c01e58a Compare July 12, 2026 21:24
@Tyler-R-Kendrick
Tyler-R-Kendrick merged commit 09640d4 into main Jul 12, 2026
3 checks passed
@Tyler-R-Kendrick
Tyler-R-Kendrick deleted the claude/harness-policy-config-gbrytt branch July 12, 2026 21:38
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