Start opencode's sandbox on Pop!_OS; lint and the smoketest now pass

The first run of lint and the full Docker smoketest since the CoreDesktop
ports found:

- opencode's sandbox didn't start. Its profile didn't allow all Unix sockets,
  so srt added its socket filter, which needs a user namespace inside
  bubblewrap, and Pop!_OS' AppArmor (bwrap-userns-restrict) denies that.
  opencode now allows them and hides their paths (/run/user, /run/dbus,
  Docker, Podman, Tailscale, X11, tmux, ssh-agent), as Hermes and Cline
  Desktop do. 80-security shows it still can't reach the session D-Bus.
- 80-security's agent list was named AGENTS, and 30-agents.sh, loaded later,
  replaced it with its own, so every sandbox check ran a command that
  doesn't exist. It's FAKE_AGENTS now.
- 50-sandbox's "can't" checks would pass if the sandbox never started; a
  check that it starts now comes first.
- shellcheck read a jq variable named done as bash's keyword (SC1010).

TEST.md says to install shellcheck and Docker, which the connector doesn't.
PLAN.md: pin srt, try the real opencode, and settle on 24.04 or 26.04.

make lint passes. smoketest/run --tier all passed every scenario but 50 and
80 before the opencode change, and 50 and 80 pass after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 19:59:14 -07:00
co-authored by Claude Opus 5.5
parent fef73e8b5b
commit c84e6d3aa0
6 changed files with 46 additions and 14 deletions
+14 -5
View File
@@ -61,9 +61,18 @@ Not ported, and why:
## Pop!_OS-specific ## Pop!_OS-specific
- [ ] `make lint` and `smoketest/run --tier all` haven't run since the ports - [ ] Pin srt. `configure.d/lib/tools.sh` installs the latest
from CoreDesktop at `4e9b962`: they were written on a machine without `@anthropic-ai/sandbox-runtime`, so a new release reaches every computer
shellcheck or Docker. The new scenarios' quick checks were run by hand; untested. One already broke opencode's sandbox: srt's Unix socket filter
`50-sandbox` and `80-security` (srt, PAM) never have been. needs a user namespace inside bubblewrap, which Pop!_OS' AppArmor
- [ ] The manual checks in [TEST.md](TEST.md) on a real Pop!_OS 24.04 machine, (`bwrap-userns-restrict`) denies. opencode now allows all Unix sockets
and hides their paths instead, as Hermes and Cline Desktop do. Pin a
version the smoketest passed with, and move the pin only after
`smoketest/run 50 80` passes on the new one.
- [ ] Start the real opencode in its sandbox on Pop!_OS, to check it needs no
socket the new `denyRead` list hides. Only a stand-in has run so far.
- [ ] The development machine runs Pop!_OS 26.04, but the smoketest still builds on Ubuntu
24.04 and smoketest/README.md says 24.04. Decide which release the
connector supports, and test on it.
- [ ] The manual checks in [TEST.md](TEST.md) on a real Pop!_OS machine,
against a real Core. None have been done yet. against a real Core. None have been done yet.
+6
View File
@@ -10,6 +10,12 @@ that cover what changed, and all of them before a release is announced.
## Automated tests ## Automated tests
They need shellcheck and Docker, which the connector doesn't install. Once:
```
sudo apt install shellcheck docker.io && sudo usermod -aG docker $USER # then log in again
```
``` ```
make lint # shellcheck, and the Python compiles make lint # shellcheck, and the Python compiles
smoketest/run # the quick scenarios smoketest/run # the quick scenarios
+2 -2
View File
@@ -115,9 +115,9 @@ OLD_NOTIFY_DONE="notify-send 'Claude Code' 'Task completed'"
# Settings written before claude-notify ran notify-send itself, so clicking # Settings written before claude-notify ran notify-send itself, so clicking
# did nothing: true while either of those two hooks is still there # did nothing: true while either of those two hooks is still there
old_claude_notifications() { old_claude_notifications() {
jq -e --arg input "$OLD_NOTIFY_INPUT" --arg done "$OLD_NOTIFY_DONE" \ jq -e --arg input "$OLD_NOTIFY_INPUT" --arg completed "$OLD_NOTIFY_DONE" \
'[.hooks.Notification[]?.hooks[]?, .hooks.Stop[]?.hooks[]? | objects | .command] '[.hooks.Notification[]?.hooks[]?, .hooks.Stop[]?.hooks[]? | objects | .command]
| any(. == $input or . == $done)' "$CLAUDE_SETTINGS" &> /dev/null | any(. == $input or . == $completed)' "$CLAUDE_SETTINGS" &> /dev/null
} }
# Your own settings are left alone: the hooks are added only if you have no # Your own settings are left alone: the hooks are added only if you have no
+14 -1
View File
@@ -4,9 +4,22 @@
"opencode.ai", "opencode.ai",
"*.opencode.ai", "*.opencode.ai",
"models.dev" "models.dev"
] ],
"allowAllUnixSockets": true
}, },
"filesystem": { "filesystem": {
"denyRead": [
"/run/user",
"/run/dbus",
"/run/docker.sock",
"/run/podman",
"/run/tailscale",
"/run/ssh-unix-local",
"/tmp/.X11-unix",
"/tmp/tmux-*",
"/tmp/ssh-*",
"/tmp/*/SingletonSocket"
],
"allowRead": [ "allowRead": [
"~/.config/opencode", "~/.config/opencode",
"~/.local/share/opencode" "~/.local/share/opencode"
+4
View File
@@ -23,6 +23,7 @@ scenario() {
cat > "$HOME/.local/bin/opencode" << 'AGENT' cat > "$HOME/.local/bin/opencode" << 'AGENT'
#!/bin/bash #!/bin/bash
case "$1" in case "$1" in
started) true ;;
read-ssh) cat ~/.ssh/id_test ;; read-ssh) cat ~/.ssh/id_test ;;
read-settings) cat ~/.config/federated-connector/core.conf ;; read-settings) cat ~/.config/federated-connector/core.conf ;;
write-home) echo x > ~/outside ;; write-home) echo x > ~/outside ;;
@@ -34,6 +35,9 @@ AGENT
cd "$project" || return cd "$project" || return
mkdir -p "$HOME/.config/federated-connector" mkdir -p "$HOME/.config/federated-connector"
echo 'CORE_DOMAIN=smoke.invalid' > "$HOME/.config/federated-connector/core.conf" echo 'CORE_DOMAIN=smoke.invalid' > "$HOME/.config/federated-connector/core.conf"
# Without this, the checks that something fails would pass if the sandbox
# itself didn't start
check "its sandbox starts" "$SANDBOX_BIN/opencode" started
check_not "it can't read ~/.ssh" "$SANDBOX_BIN/opencode" read-ssh check_not "it can't read ~/.ssh" "$SANDBOX_BIN/opencode" read-ssh
check "unsandboxed, Federated Connector's settings are readable" "$SANDBOX_BIN/unsandboxed" opencode read-settings check "unsandboxed, Federated Connector's settings are readable" "$SANDBOX_BIN/unsandboxed" opencode read-settings
check_not "it can't read Federated Connector's settings" "$SANDBOX_BIN/opencode" read-settings check_not "it can't read Federated Connector's settings" "$SANDBOX_BIN/opencode" read-settings
+6 -6
View File
@@ -18,7 +18,7 @@ PRIVILEGED=1
# runs it exactly as it would run opencode, Hermes or Cline Desktop: same # runs it exactly as it would run opencode, Hermes or Cline Desktop: same
# config, same srt, same proxy. # config, same srt, same proxy.
AGENTS=(opencode hermes cline-desktop) FAKE_AGENTS=(opencode hermes cline-desktop)
FAKE_BIN="$HOME/smoketest-agents" FAKE_BIN="$HOME/smoketest-agents"
# Where opencode and Hermes are started; Cline Desktop always starts in ~/Projects # Where opencode and Hermes are started; Cline Desktop always starts in ~/Projects
PROJECT="$HOME/Projects/smoketest-project" PROJECT="$HOME/Projects/smoketest-project"
@@ -84,7 +84,7 @@ outside() {
blocked() { blocked() {
local agent local agent
check "outside the sandbox: $1" outside "$2" check "outside the sandbox: $1" outside "$2"
for agent in "${AGENTS[@]}"; do for agent in "${FAKE_AGENTS[@]}"; do
check "$agent: $1" fails_in "$agent" "$2" check "$agent: $1" fails_in "$agent" "$2"
done done
} }
@@ -105,7 +105,7 @@ write_stays_in() {
write_blocked() { write_blocked() {
local agent local agent
check "outside the sandbox: $1" outside "[ -w \"\$(dirname $2)\" ] && { [ ! -e $2 ] || [ -w $2 ]; }" check "outside the sandbox: $1" outside "[ -w \"\$(dirname $2)\" ] && { [ ! -e $2 ] || [ -w $2 ]; }"
for agent in "${AGENTS[@]}"; do for agent in "${FAKE_AGENTS[@]}"; do
check "$agent: $1" write_stays_in "$agent" "$2" "smoketest-escape-$agent" check "$agent: $1" write_stays_in "$agent" "$2" "smoketest-escape-$agent"
done done
} }
@@ -118,7 +118,7 @@ setup_sandbox() {
mkdir -p "$FAKE_BIN" "$PROJECT" "$HOME/smoketest-other" "$HOME/.local/bin" \ mkdir -p "$FAKE_BIN" "$PROJECT" "$HOME/smoketest-other" "$HOME/.local/bin" \
"$HOME/.config/systemd/user" "$HOME/.config/autostart" "$(dirname "$USER_SANDBOX_CONF")" "$HOME/.config/systemd/user" "$HOME/.config/autostart" "$(dirname "$USER_SANDBOX_CONF")"
for agent in "${AGENTS[@]}"; do for agent in "${FAKE_AGENTS[@]}"; do
printf '#!/bin/bash\nexec bash "$@"\n' > "$FAKE_BIN/$agent" printf '#!/bin/bash\nexec bash "$@"\n' > "$FAKE_BIN/$agent"
chmod +x "$FAKE_BIN/$agent" chmod +x "$FAKE_BIN/$agent"
done done
@@ -155,7 +155,7 @@ sandbox_checks() {
step "The sandbox: what agents must be able to do, or the rest proves nothing" step "The sandbox: what agents must be able to do, or the rest proves nothing"
setup_sandbox setup_sandbox
lan="http://$LAN_IP" lan="http://$LAN_IP"
for agent in "${AGENTS[@]}"; do for agent in "${FAKE_AGENTS[@]}"; do
check "$agent: writes in the folder it started in" works_in "$agent" 'echo x > ./smoketest-probe && rm ./smoketest-probe' check "$agent: writes in the folder it started in" works_in "$agent" 'echo x > ./smoketest-probe && rm ./smoketest-probe'
check "$agent: writes in /tmp" works_in "$agent" 'echo x > /tmp/smoketest-probe-$$ && rm /tmp/smoketest-probe-$$' check "$agent: writes in /tmp" works_in "$agent" 'echo x > /tmp/smoketest-probe-$$ && rm /tmp/smoketest-probe-$$'
check "$agent: reaches an allowed domain through its proxy" works_in "$agent" 'curl -sf -o /dev/null -m 20 https://github.com/' check "$agent: reaches an allowed domain through its proxy" works_in "$agent" 'curl -sf -o /dev/null -m 20 https://github.com/'
@@ -197,7 +197,7 @@ sandbox_checks() {
source "$CONNECTOR/configure.d/lib/json.sh" source "$CONNECTOR/configure.d/lib/json.sh"
check "allow one LAN server, as configure ai-servers does" \ check "allow one LAN server, as configure ai-servers does" \
edit_json "$USER_SANDBOX_CONF" '{}' --arg s "$LAN_IP:$LAN_PORT" '.network.allowedDomains += [$s]' edit_json "$USER_SANDBOX_CONF" '{}' --arg s "$LAN_IP:$LAN_PORT" '.network.allowedDomains += [$s]'
for agent in "${AGENTS[@]}"; do for agent in "${FAKE_AGENTS[@]}"; do
check "$agent: reaches the allowed LAN server" works_in "$agent" "curl -sf -m 10 $lan:$LAN_PORT/" check "$agent: reaches the allowed LAN server" works_in "$agent" "curl -sf -m 10 $lan:$LAN_PORT/"
done done
blocked "reaches another port on the allowed LAN server" "curl -sf -m 10 $lan:$LAN_PORT_OTHER/" blocked "reaches another port on the allowed LAN server" "curl -sf -m 10 $lan:$LAN_PORT_OTHER/"