Files
alzeo/dashboard/opencode-web.service.template
T
Hasan BasbunarandClaude Fable 5.2 cf7c07798a opencode guard: the report's hosts are denied to webfetch too, on both majors
Since v1.40.4 the box's opencode configs deny a shell command naming an Alibaba Cloud host or a
cloud metadata address. On 2026-11-21 the same kind of request left this box as a webfetch tool
call, twice, which no shell rule sees (decision 1561). The same three patterns are now written
for the webfetch tool.

1.x: a block "webfetch*" after "bash*" at the end of "permission" (the plain key "webfetch"
cannot hold an object: 1.19.5 refuses the config), and "*webfetch" after "*bash" in the unit's
OPENCODE_PERMISSION. A block already last and intact is not rewritten, so a box of an earlier
release gets "webfetch*" after its "bash*" and nothing else of its file moves. A block the person
set to one action is theirs: "deny" stands while no key after it speaks for the tool again,
anything else is said (rc 1) and the other block is written still.

2.x: three webfetch rules after the three shell ones, in "permissions" and in the unit's
OPENCODE_CONFIG_CONTENT. A box that served 2.x on v1.56.0 gets the three new rules once; the
rollback to 1.x and the uninstall recognise both shapes of the array, and an empty array is the
person's, not ours.

The unit's values stay this repo's rules alone. On OpenCode 2 the unit's allow overrides every
deny rule of the person's own configs (the content merges after every file): the install's note
said "unless your config has one after it", which no file can have, and now says what happens.

Measured on the real binaries against a scripted endpoint asking for a webfetch whose URL names
aliyuncs.com and points at 127.0.0.1: 1.19.5 and 1.19.6 fetch it with no rule and refuse it with
"webfetch*" and with "*webfetch"; 2.3.2 fetches it under the wildcard allow alone and answers
permission.rejected with the rule after it. Tests red on the old code, green now.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 15:45:10 +01:00

47 lines
2.3 KiB
Plaintext

[Unit]
Description=opencode web server for the Spark Cockpit Agent tab (loopback :__OPENCODE_PORT__)
Documentation=https://github.com/hasso5703/dgx-spark-qwen38
After=network.target
[Service]
Type=simple
User=__USER__
Group=__GROUP__
WorkingDirectory=__HOME__
Environment=HOME=__HOME__
# Your PATH at install time, so the agent's tools (git, node, uvx for the MCP
# servers, opencode itself) resolve the way they do in your terminal.
Environment=PATH=__PATH__
# The Basic credentials the cockpit relay presents (OPENCODE_SERVER_USERNAME and
# OPENCODE_SERVER_PASSWORD), generated once by install-agent.sh, mode 0600.
EnvironmentFile=__HOME__/.config/qwen38/opencode-web.env
# The output ceiling, or (OpenCode 2) the word that there is none to lift: this whole
# block is rendered by install-agent.sh for the OpenCode that runs.
__CAP_LINE__
# The box's own providers and default model, whatever your global opencode config
# says: opencode loads this file over it (a missing file is ignored). Without it a
# fresh box's Agent tab had only opencode's hosted provider and answered with its free
# cloud model, big-pickle, instead of the model this box serves (2026-09-23).
Environment=OPENCODE_CONFIG=__HOME__/.config/qwen38/opencode.json
# Tool permissions. opencode's own defaults ask before a tool touches a path outside
# the session's project and on a repeated identical call; AGENT_AUTO=1 at install
# approves every tool call instead, the same autonomy as the oc launcher's --yolo
# (1.x) or --auto (2.x). install-agent.sh renders this line for the OpenCode that
# runs: 1.x reads OPENCODE_PERMISSION, merged after the config files; 2.x ignores that
# variable entirely and reads OPENCODE_CONFIG_CONTENT, merged after them too, where the
# wildcard allow comes first and this repo's shell and webfetch rules for the hosts of
# Alibaba Cloud and the cloud metadata addresses come again after it (SECURITY.md, and
# measured on 2.3.0 the 2026-11-14: the denies hold under the wildcard).
__AUTO_LINE__
# Loopback only: the cockpit relay is the one thing that reaches this server.
ExecStart=__OPENCODE_BIN__ serve --hostname 127.0.0.1 --port __OPENCODE_PORT__ __SERVE_FLAGS__
Restart=always
RestartSec=3
# A stop takes the MCP servers and any tool the agent still runs down with it.
KillMode=control-group
TimeoutStopSec=20
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target