fix(policy): allow npm child process and Vertex AI egress for opencode - #92
Open
yvonnedevlinrh wants to merge 1 commit into
Open
fix(policy): allow npm child process and Vertex AI egress for opencode#92yvonnedevlinrh wants to merge 1 commit into
yvonnedevlinrh wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #91
Summary
The
opencodenetwork policy (in bothsandboxes/base/policy.yamlandsandboxes/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.orgis already allowlisted as an endpoint, but thenpmbinary is not in the policy'sbinaries:list. Policy pairs are(binary, endpoint), so when opencode spawns a backgroundnpm install(arborist), the connecting process is/usr/local/bin/npm(or/usr/bin/npm) — not the allowlisted opencode/node binaries - and its CONNECT toregistry.npmjs.orgis denied.This is not TLS-MITM:
registry.npmjs.orgis a plain CONNECT tunnel (notls: terminate). It is purely a binary allowlist gap. Thedroidandollamasandboxes already ship dedicatednpmpolicies;opencodenever allowlisted npm.Fix: add
/usr/local/bin/npmand/usr/bin/npmto thebinaries:allowlist.2. No Google / Vertex AI egress
The
opencodepolicy had zero Google hosts, so running OpenCode against agoogle-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
geminipolicy) plussts.googleapis.com, which GitHub-OIDC WIF additionally requires for token exchange. Also addmodels.opencode.aiso opencode does not silently fall back to its built-in default model.Changes
*-aiplatform.googleapis.com,sts.googleapis.com,oauth2.googleapis.com,www.googleapis.com,iamcredentials.googleapis.com,accounts.google.comadded to endpointsmodels.opencode.aiadded to endpoints/usr/local/bin/npm,/usr/bin/npmadded to binariesEnvironment
nvcr.io/nvidia/base/ubuntu:noble-20251013(Ubuntu 24.04)22.22.1-1nodesource1, npm11.11.0,opencode-ai@1.2.18(global)Testing
python3 -c "import yaml; yaml.safe_load(...)"passes for both files.