fix(policy): convert npm_registry from access: full to REST GET-only#1356
fix(policy): convert npm_registry from access: full to REST GET-only#1356latenighthackathon wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
📝 WalkthroughWalkthroughReplaced the npm registry endpoint in the sandbox policy from L4 Changes
Sequence Diagram(s)sequenceDiagram
participant Agent as "NemoClaw Agent"
participant Proxy as "Policy Proxy\n(protocol: rest, enforcement: enforce, tls: terminate)"
participant NPM as "registry.npmjs.org:443\n(NPM Registry)"
Agent->>Proxy: HTTPS GET /package... (TLS)
Proxy->>Proxy: TLS terminated\nEvaluate rules (allow only GET /**)
alt allowed
Proxy->>NPM: Forward REST GET (established TLS)
NPM-->>Proxy: 200 OK + package tarball
Proxy-->>Agent: 200 OK + package tarball
else denied
Proxy-->>Agent: 403 Forbidden
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@nemoclaw-blueprint/policies/openclaw-sandbox.yaml`:
- Around line 159-165: The npm registry endpoint configuration (the host block
for registry.npmjs.org in openclaw-sandbox.yaml) is incompatible with npm CLI's
CONNECT tunneling when using tls: terminate and protocol: rest; change this
endpoint to use access: full (matching the npm preset) or switch protocol to one
that supports CONNECT/tunneling, set enforcement appropriately (e.g., access:
full instead of enforcement: enforce), and add HEAD to the allowed rules
(alongside GET) so npm metadata checks succeed; update the host block for
registry.npmjs.org accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e43a2d77-e841-41a9-9eb8-fc7297c69106
📒 Files selected for processing (1)
nemoclaw-blueprint/policies/openclaw-sandbox.yaml
| - host: registry.npmjs.org | ||
| port: 443 | ||
| access: full | ||
| protocol: rest | ||
| enforcement: enforce | ||
| tls: terminate | ||
| rules: | ||
| - allow: { method: GET, path: "/**" } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if npm preset documents CONNECT tunneling requirement and verify
# if there's any documentation about npm_registry vs npm preset differences.
echo "=== Checking npm preset for CONNECT/tunneling documentation ==="
fd -t f 'npm.yaml' --exec cat {}
echo ""
echo "=== Searching for CONNECT tunneling documentation in policies ==="
rg -n -i 'connect|tunnel' --type yaml
echo ""
echo "=== Checking if HEAD method is used elsewhere in policies ==="
rg -n 'method:\s*HEAD' --type yamlRepository: NVIDIA/NemoClaw
Length of output: 1630
🏁 Script executed:
# Check the test file referenced in the review (test/policies.test.js lines 200-226)
cat -n test/policies.test.js | sed -n '195,230p'Repository: NVIDIA/NemoClaw
Length of output: 1648
🏁 Script executed:
# Also search for any npm preset or npm_registry configuration in sandbox yaml
rg -n 'npm' nemoclaw-blueprint/policies/openclaw-sandbox.yaml -B 2 -A 5Repository: NVIDIA/NemoClaw
Length of output: 835
npm CLI likely incompatible with tls: terminate configuration.
The test suite at test/policies.test.js:200-211 explicitly documents that "Package managers (pip, npm, yarn) use CONNECT tunneling which breaks under tls: terminate" and verifies the npm preset uses access: full specifically to support this behavior. The npm_registry endpoint in sandbox.yaml diverges from this pattern by using protocol: rest, enforcement: enforce, and tls: terminate with GET-only rules.
Since npm CLI requires CONNECT tunneling for HTTPS connections through proxies, this configuration will break npm install commands despite the comment claiming support for this use case. Either:
- Change
npm_registryto useaccess: full(like the npm preset), or - Document why npm_registry is expected to work differently than the npm preset.
Consider adding HEAD method to rules if npm checks package metadata before download.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nemoclaw-blueprint/policies/openclaw-sandbox.yaml` around lines 159 - 165,
The npm registry endpoint configuration (the host block for registry.npmjs.org
in openclaw-sandbox.yaml) is incompatible with npm CLI's CONNECT tunneling when
using tls: terminate and protocol: rest; change this endpoint to use access:
full (matching the npm preset) or switch protocol to one that supports
CONNECT/tunneling, set enforcement appropriately (e.g., access: full instead of
enforcement: enforce), and add HEAD to the allowed rules (alongside GET) so npm
metadata checks succeed; update the host block for registry.npmjs.org
accordingly.
ac66db0 to
fa3b127
Compare
Replace L4 pass-through (access: full) with L7-enforced REST policy restricted to GET. Agents only fetch packages from the npm registry and never publish, so write methods are not needed. Enables per-request rule evaluation, per-request logging, and SecretResolver credential injection on this endpoint. Closes NVIDIA#1355 Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
fa3b127 to
3ba9abf
Compare
|
Closing to refile with clean commit history. |
Summary
access: full) onnpm_registryendpoint with L7-enforced REST policy restricted toGET /**Motivation
npm_registryalongside the GitHub endpointsTest plan
openclaw plugins installsucceeds with GET-only policynpm installinside sandbox completes normallynpm publish) are blocked by the policyCloses #1355
Summary by CodeRabbit