From 48dfe92ff01ebfe2b9c121076d1599beb3d5bfcf Mon Sep 17 00:00:00 2001 From: Yvonne Devlin Date: Thu, 27 Aug 2026 11:12:18 +0000 Subject: [PATCH] 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 --- sandboxes/base/policy.yaml | 20 ++++++++++++++++++++ sandboxes/gemini/policy.yaml | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/sandboxes/base/policy.yaml b/sandboxes/base/policy.yaml index 98637fe4..a86df304 100644 --- a/sandboxes/base/policy.yaml +++ b/sandboxes/base/policy.yaml @@ -177,12 +177,32 @@ network_policies: port: 443 - host: opencode.ai port: 443 + - host: models.opencode.ai + port: 443 - host: integrate.api.nvidia.com port: 443 + # Google Vertex AI + token endpoints (mirrors gemini policy). sts is + # additionally required for GitHub-OIDC Workload Identity Federation. + - host: "*-aiplatform.googleapis.com" + port: 443 + - host: sts.googleapis.com + port: 443 + - host: oauth2.googleapis.com + port: 443 + - host: www.googleapis.com + port: 443 + - host: iamcredentials.googleapis.com + port: 443 + - host: accounts.google.com + port: 443 binaries: - path: /usr/lib/node_modules/opencode-ai/bin/.opencode - path: /usr/bin/node - path: /usr/local/bin/opencode + # npm child process (background dependency install / arborist) connects + # as npm, not opencode/node, so it must be allowlisted explicitly. + - path: /usr/local/bin/npm + - path: /usr/bin/npm codex: name: codex diff --git a/sandboxes/gemini/policy.yaml b/sandboxes/gemini/policy.yaml index 22218f2e..b0567323 100644 --- a/sandboxes/gemini/policy.yaml +++ b/sandboxes/gemini/policy.yaml @@ -160,12 +160,32 @@ network_policies: port: 443 - host: opencode.ai port: 443 + - host: models.opencode.ai + port: 443 - host: integrate.api.nvidia.com port: 443 + # Google Vertex AI + token endpoints. sts is additionally required + # for GitHub-OIDC Workload Identity Federation. + - host: "*-aiplatform.googleapis.com" + port: 443 + - host: sts.googleapis.com + port: 443 + - host: oauth2.googleapis.com + port: 443 + - host: www.googleapis.com + port: 443 + - host: iamcredentials.googleapis.com + port: 443 + - host: accounts.google.com + port: 443 binaries: - path: /usr/lib/node_modules/opencode-ai/bin/.opencode - path: /usr/bin/node - path: /usr/local/bin/opencode + # npm child process (background dependency install / arborist) + # connects as npm, not opencode/node, so allowlist it explicitly. + - path: /usr/local/bin/npm + - path: /usr/bin/npm copilot: name: copilot