mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(sandbox): add git credential forwarding toggle to settings
This commit is contained in:
1 parent
19b91ac24f
commit
d7f4f2f110
8 files changed
+135
-26
No files matched your search
@@ -319,14 +319,16 @@ With a fresh Docker volume, first startup imports the host OpenCode config and s
|
||||
|
||||
## Agent Sandboxing Overlay
|
||||
|
||||
Optional KVM-backed agent sandboxing (see [Agent Sandboxing](../features/sandboxing.md)). The sandbox overlay (`docker-compose.sandbox.yml`) grants the container KVM access, passes sandbox tuning through from `.env`, and persists microsandbox state:
|
||||
Optional KVM-backed agent sandboxing (see [Agent Sandboxing](../features/sandboxing.md)). The sandbox overlay (`docker-compose.sandbox.yml`) grants the container KVM and guest-networking access, passes sandbox tuning through from `.env`, and persists microsandbox state. It deliberately avoids `privileged: true`, granting only the specific devices and capability `msb` needs:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
app:
|
||||
privileged: true
|
||||
devices:
|
||||
- "/dev/kvm:/dev/kvm"
|
||||
- "/dev/net/tun:/dev/net/tun"
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
environment:
|
||||
- SANDBOX_IMAGE=${SANDBOX_IMAGE:-docker.io/cstechdev/ocm-sandbox:latest}
|
||||
- SANDBOX_MEMORY=${SANDBOX_MEMORY:-4G}
|
||||
@@ -349,7 +351,7 @@ Start the Manager with the overlay:
|
||||
docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d
|
||||
```
|
||||
|
||||
The overlay requires a Linux host with `/dev/kvm`. Docker Desktop on macOS and Windows cannot provide `/dev/kvm`, so the sandbox toggle in Settings stays disabled there.
|
||||
The overlay requires a Linux host with `/dev/kvm`. Docker Desktop on macOS and Windows cannot provide `/dev/kvm`, so the sandbox toggle in Settings stays disabled there. `/dev/net/tun` and `NET_ADMIN` provide guest networking for `SANDBOX_NET=public`; if `msb` reports a missing device or capability on a particular host, add that specific entry rather than enabling full privilege.
|
||||
|
||||
`SANDBOX_EXEC_USER` defaults to the numeric `PUID` (falling back to `1000`), and the Manager runs every sandboxed command as that numeric uid (with the Manager's gid). Because the entrypoint realigns the container's `node` account to `PUID`/`PGID` and re-owns `/workspace`, a non-1000 `PUID` (for example `PUID=1001`) writes to the mounted repositories with the same identity as the workspace owner. If a configured `SANDBOX_EXEC_USER` cannot match the workspace owner, the toggle reports enforcement as unavailable instead of running broken commands.
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ Forwarding is opt-in, off by default:
|
||||
| Scope | Where | Effect |
|
||||
| --- | --- | --- |
|
||||
| Global | Settings → Sandbox → *Git credentials in sandbox* (`preferences.sandbox.gitCredentials`) | Default for every repo |
|
||||
| Per repo | `repo_settings.sandboxGitCredentials` | Overrides the global default in either direction |
|
||||
| Per repo | `repo_settings.sandboxGitCredentials` | Overrides the global default in either direction. The planner honours it when resolving credentials, but nothing writes it yet — there is no UI or API for the per-repo override |
|
||||
|
||||
When enabled, the planner resolves credentials on the host and the shim forwards them into the microVM with `msb exec -e`:
|
||||
|
||||
@@ -148,9 +148,9 @@ When enabled, the planner resolves credentials on the host and the shim forwards
|
||||
- `GIT_AUTHOR_*` / `GIT_COMMITTER_*` so `git commit` has an identity, and `GH_TOKEN` / `GITHUB_TOKEN` for `gh`.
|
||||
- At most 16 hosts. Beyond that the Manager logs a warning and forwards the first 16 rather than emitting a `GIT_CONFIG_COUNT` that git would reject.
|
||||
|
||||
Credentials are resolved per command, so changing a credential takes effect on the next sandboxed command without restarting the OpenCode server.
|
||||
Both the switch and the credentials themselves are resolved per command, so turning forwarding on or off, or changing a credential, takes effect on the next sandboxed command without restarting the OpenCode server. Only the sandbox enable toggle requires a restart.
|
||||
|
||||
Understand the trade-off before enabling it. `msb exec -e` is the only injection mechanism microsandbox offers, so the token is visible in the `msb` process arguments on the host and in the guest environment for that command's lifetime. A prompt-injected agent inside the microVM can read and exfiltrate any credential you forward. Leave it off for repos where the agent handles untrusted input, and prefer per-repo opt-in over the global switch.
|
||||
Understand the trade-off before enabling it. `msb exec -e` is the only injection mechanism microsandbox offers, so the token is visible in the `msb` process arguments on the host and in the guest environment for that command's lifetime. A prompt-injected agent inside the microVM can read and exfiltrate any credential you forward. The global switch is the only exposed control today, so enabling it applies to every repo; leave it off while any agent handles untrusted input.
|
||||
|
||||
## Sandbox Guest Image
|
||||
|
||||
|
||||
Reference in new issue
Block a user