The opencode network policy allowlists registry.npmjs.org as an endpoint
but not the npm binary, so opencode's background dependency install
(arborist) connects as /usr/local/bin/npm and is denied (ECONNRESET).
Add /usr/local/bin/npm and /usr/bin/npm to the binaries allowlist,
matching the dedicated npm policies in the droid and ollama sandboxes.
The policy also had no Google egress, so running opencode against a
google-vertex-* provider could not reach Vertex AI or the Google token
endpoints. Add the Vertex AI + token hosts (mirroring the gemini policy)
plus sts.googleapis.com, which GitHub-OIDC Workload Identity Federation
requires for token exchange. Also add models.opencode.ai so opencode
does not silently fall back to its built-in default model.
Applied identically to the base and gemini sandbox policies.
Signed-off-by: Yvonne Devlin <ydevlin@redhat.com>
Refs #91
Summary
The opencode network policy (in both sandboxes/base/policy.yaml and sandboxes/gemini/policy.yaml) has two egress gaps that break real-world OpenCode usage. This PR fixes both, applied identically to the base and gemini sandbox policies.
1. npm installs fail with ECONNRESET (binary allowlist gap)
registry.npmjs.org is already allowlisted as an endpoint, but the npm binary is not in the policy's binaries: list. Policy pairs are (binary, endpoint), so when opencode spawns a background npm install (arborist), the connecting process is /usr/local/bin/npm (or /usr/bin/npm) — not the allowlisted opencode/node binaries - and its CONNECT to registry.npmjs.org is denied.
This is not TLS-MITM: registry.npmjs.org is a plain CONNECT tunnel (no tls: terminate). It is purely a binary allowlist gap. The droid and ollama sandboxes already ship dedicated npm policies; opencode never allowlisted npm.
Fix: add /usr/local/bin/npm and /usr/bin/npm to the binaries: allowlist.
2. No Google / Vertex AI egress
The opencode policy had zero Google hosts, so running OpenCode against a google-vertex-* provider (Vertex AI, including GitHub-OIDC Workload Identity Federation) could not reach the required Google endpoints - both token exchange and inference fail.
Fix: add the Vertex AI + Google token hosts (mirroring the gemini policy) plus sts.googleapis.com, which GitHub-OIDC WIF additionally requires for token exchange. Also add models.opencode.ai so opencode does not silently fall back to its built-in default model.
Changes
Environment
Testing