Ports CoreDesktop's e991264, 05b13b2 and d974b91. configure agents allowed Hermes' gateway the host in MATRIX_HOMESERVER from ~/.hermes/.env, which Hermes can write from inside its sandbox, so it could open the way out to any host it chose. The allowed server is now in ~/.config/federated-connector/sandbox/hermes.json, which no sandbox can write. configure hermes is to do while Hermes names a server you haven't allowed, and asks about only that; configure agents says so. Only a plain host name counts, so it can't be a wildcard or carry escape codes into the question. sandbox/agent no longer reads FEDERATED_SANDBOX_DOMAINS. The server an old drop-in allows is carried over, read from the drop-in itself, when the gateway starts and when configure agents rewrites it, so a working gateway keeps working. Agents could read ~/.config/federated-connector, which has the Core's domain and user name; base.json now hides it. edit_json treats an empty settings file like a missing one: jq reads no JSON from an empty file and writes nothing back, so configure ai-servers said a server was added while the sandbox still blocked it. agent_path joined the last folder on PATH to ~/.local/bin, so an agent there wasn't found when ~/.local/bin wasn't on PATH (e.g. in a service). Smoketest: 55-hermes-homeserver, and 50-sandbox checks that an agent can't read the connector's settings. PLAN.md drops what's done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
2.4 KiB
Bash
54 lines
2.4 KiB
Bash
# shellcheck shell=bash
|
|
# Scenarios set what the runner and items read
|
|
# shellcheck disable=SC2034
|
|
DESCRIPTION="Node.js and srt download; a stand-in agent in the sandbox"
|
|
TIER=all
|
|
PRIVILEGED=1
|
|
|
|
scenario() {
|
|
local project="$HOME/Projects/demo" out
|
|
source "$CONNECTOR/configure.d/30-agents.sh"
|
|
sudo apt-get update > /dev/null && sudo apt-get install -y "${SANDBOX_PACKAGES[@]}" > /dev/null 2>&1
|
|
check "bubblewrap works" bwrap_works
|
|
|
|
step "Node.js and srt"
|
|
check_not "Ubuntu's Node.js, if any, isn't new enough or isn't there" node_ok
|
|
check "install_srt" install_srt
|
|
check "Node.js is in ~/.local/share/federated-connector/node" test -x "$FC_TOOLS/node/bin/node"
|
|
check "srt is found" srt_path
|
|
|
|
step "A stand-in agent"
|
|
mkdir -p "$HOME/.local/bin" "$HOME/.ssh" "$project"
|
|
echo secret > "$HOME/.ssh/id_test"
|
|
cat > "$HOME/.local/bin/opencode" << 'AGENT'
|
|
#!/bin/bash
|
|
case "$1" in
|
|
read-ssh) cat ~/.ssh/id_test ;;
|
|
read-settings) cat ~/.config/federated-connector/core.conf ;;
|
|
write-home) echo x > ~/outside ;;
|
|
write-here) echo x > ./inside ;;
|
|
fetch) curl -sf -o /dev/null --max-time 20 "$2" ;;
|
|
esac
|
|
AGENT
|
|
chmod +x "$HOME/.local/bin/opencode"
|
|
cd "$project" || return
|
|
mkdir -p "$HOME/.config/federated-connector"
|
|
echo 'CORE_DOMAIN=smoke.invalid' > "$HOME/.config/federated-connector/core.conf"
|
|
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_not "it can't read Federated Connector's settings" "$SANDBOX_BIN/opencode" read-settings
|
|
check_not "it can't write outside its project" "$SANDBOX_BIN/opencode" write-home
|
|
check "it can write in its project" "$SANDBOX_BIN/opencode" write-here
|
|
check "it reaches an allowed site" "$SANDBOX_BIN/opencode" fetch https://registry.npmjs.org/
|
|
check_not "it doesn't reach others" "$SANDBOX_BIN/opencode" fetch https://example.com/
|
|
check "unsandboxed runs it directly" "$SANDBOX_BIN/unsandboxed" opencode write-home
|
|
cd "$HOME" || return
|
|
out="$("$SANDBOX_BIN/opencode" write-here 2>&1)"
|
|
check "it won't start in your home folder" grep -q "Start opencode from a project directory" <<< "$out"
|
|
|
|
step "Typing its name runs it in the sandbox"
|
|
check "put_on_path" put_on_path
|
|
check "on_path" on_path
|
|
check_eq "a new bash finds the sandboxed one first" "$SANDBOX_BIN/opencode" "$(bash -ic 'command -v opencode' < /dev/null 2> /dev/null)"
|
|
}
|