Skip to content

Commit 48dfe92

Browse files
fix(policy): allow npm child process and Vertex AI egress for opencode
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>
1 parent fffb6b2 commit 48dfe92

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

sandboxes/base/policy.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,32 @@ network_policies:
177177
port: 443
178178
- host: opencode.ai
179179
port: 443
180+
- host: models.opencode.ai
181+
port: 443
180182
- host: integrate.api.nvidia.com
181183
port: 443
184+
# Google Vertex AI + token endpoints (mirrors gemini policy). sts is
185+
# additionally required for GitHub-OIDC Workload Identity Federation.
186+
- host: "*-aiplatform.googleapis.com"
187+
port: 443
188+
- host: sts.googleapis.com
189+
port: 443
190+
- host: oauth2.googleapis.com
191+
port: 443
192+
- host: www.googleapis.com
193+
port: 443
194+
- host: iamcredentials.googleapis.com
195+
port: 443
196+
- host: accounts.google.com
197+
port: 443
182198
binaries:
183199
- path: /usr/lib/node_modules/opencode-ai/bin/.opencode
184200
- path: /usr/bin/node
185201
- path: /usr/local/bin/opencode
202+
# npm child process (background dependency install / arborist) connects
203+
# as npm, not opencode/node, so it must be allowlisted explicitly.
204+
- path: /usr/local/bin/npm
205+
- path: /usr/bin/npm
186206

187207
codex:
188208
name: codex

sandboxes/gemini/policy.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,32 @@ network_policies:
160160
port: 443
161161
- host: opencode.ai
162162
port: 443
163+
- host: models.opencode.ai
164+
port: 443
163165
- host: integrate.api.nvidia.com
164166
port: 443
167+
# Google Vertex AI + token endpoints. sts is additionally required
168+
# for GitHub-OIDC Workload Identity Federation.
169+
- host: "*-aiplatform.googleapis.com"
170+
port: 443
171+
- host: sts.googleapis.com
172+
port: 443
173+
- host: oauth2.googleapis.com
174+
port: 443
175+
- host: www.googleapis.com
176+
port: 443
177+
- host: iamcredentials.googleapis.com
178+
port: 443
179+
- host: accounts.google.com
180+
port: 443
165181
binaries:
166182
- path: /usr/lib/node_modules/opencode-ai/bin/.opencode
167183
- path: /usr/bin/node
168184
- path: /usr/local/bin/opencode
185+
# npm child process (background dependency install / arborist)
186+
# connects as npm, not opencode/node, so allowlist it explicitly.
187+
- path: /usr/local/bin/npm
188+
- path: /usr/bin/npm
169189

170190
copilot:
171191
name: copilot

0 commit comments

Comments
 (0)