Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ RUN apt-get update && apt-get install -y \
ca-certificates gnupg lsb-release \
python3 python3-pip python3-venv \
maven \
golang \
chromium-browser \
gping bind9-dnsutils iproute2 iputils-ping \
xclip \
xsel \
&& rm -rf /var/lib/apt/lists/*
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ sandbox-code [options] [-- command...]
|---|---|
| `-w`, `--workspace PATH` | Directory to mount as `/workspace` (default: current directory) |
| `--bash` | Start an interactive bash shell instead of OpenCode |
| `--version` | Print OpenCode version and exit |
| `--ssh` | Mount `~/.ssh` into the container (read-only) |
| `--github` | Mount `~/.ssh` (read-only) and `~/.config/gh` (writable) |
| `--x11` | Mount X11 socket for clipboard support (enables copy/paste) |
| `--no-network` | Disable all networking (`--network none`) |
| `--network NAME` | Use a specific Docker network (default: bridge) |
| `--blacklist` | Isolate from local/Tailscale subnets, allow internet (`blacklist-networks.conf`) |
| `--whitelist` | Allow only listed CIDRs, block everything else (`whitelist-networks.conf`) |
| `--clean-rules` | Remove firewall rules created by `--blacklist` / `--whitelist` |
| `--no-git` | Hide `.git` directory (tmpfs over `/workspace/.git`) |
| `--reset` | Delete all persistent data before starting |
| `--no-cache` | Force a full Docker image rebuild without layer cache |

Expand All @@ -83,6 +91,33 @@ To wipe everything and start fresh:
sandbox-code --reset
```

## Network isolation

Use `--blacklist` or `--whitelist` to restrict outbound traffic from the container.
Both require `sudo` to apply iptables/nftables rules on the host.

| Flag | Config file | Behaviour |
|---|---|---|
| `--blacklist` | `blacklist-networks.conf` | Block listed CIDRs, allow everything else |
| `--whitelist` | `whitelist-networks.conf` | Allow only listed CIDRs, block everything else |

Config file format (first two lines = Docker network name + subnet, rest = CIDRs):

```
sandbox-code-blacklist
172.30.0.0/16
# comments start with #
10.0.0.0/8
192.168.0.0/16
100.64.0.0/10
```

Clean up firewall rules:

```bash
sandbox-code --clean-rules
```

## Image contents

| Tool | Version |
Expand Down
10 changes: 10 additions & 0 deletions blacklist-networks.conf

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

idem per whitelist-networks.conf

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

certo

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sandbox-code-caged
172.30.0.0/16
# Blocked CIDRs — one per line
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
# Tailscale / CGNAT
100.64.0.0/10
# Link-local
169.254.0.0/16
Loading