feat: add cargo, go, apt, and ghcr policy presets#141
Conversation
74a27f3 to
1ade1da
Compare
1ade1da to
2b4c6a5
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds four new network-policy preset YAMLs (apt, cargo, ghcr, go) defining registry endpoints (mostly on port 443) with protocol/ enforcement details and binaries lists. Tests updated to expect the expanded presets and validate the new preset endpoints. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
test/policies.test.js (1)
12-27: Avoid dual source of truth for preset totals.Line 14 hardcodes
13while Line 26 already defines the expected preset set. Consider deriving the count assertion from the expected list length to keep these checks in sync.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/policies.test.js` around lines 12 - 27, The test contains a duplicated source of truth: the hardcoded count 13 in the "returns all 13 presets" assertion and the explicit expected array in the "returns expected preset names" test; replace the numeric literal with a reference to the expected list length so they stay in sync by deriving the count from the expected array (use the same expected array used in the second test or move it to a shared variable) and assert that policies.listPresets().length equals expected.length; reference policies.listPresets, the presets/names variables and the expected array when making the change.nemoclaw-blueprint/policies/presets/ghcr.yaml (1)
18-19: Scope POST rule to specific OCI v2 API paths rather than/**(least privilege).Line 19 currently allows
POSTon/**. While POST is necessary for push operations (e.g., starting blob uploads viaPOST /v2/<name>/blobs/uploads/), it should be scoped to the OCI Registry v2 API paths (e.g.,/v2/**) instead of allowing it globally. This reduces the attack surface while still supporting docker push.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@nemoclaw-blueprint/policies/presets/ghcr.yaml` around lines 18 - 19, Replace the overly-broad POST rule "- allow: { method: POST, path: "/**" }" with a scoped rule that only permits POST to the OCI v2 registry paths (for example "- allow: { method: POST, path: "/v2/**" }") so POST actions (like initiating blob uploads) are limited to /v2/* endpoints; update the corresponding entry in the YAML preset (the POST allow mapping) to use "/v2/**" instead of "/**".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/policies.test.js`:
- Around line 144-148: The test title "ghcr preset has registry and token
endpoints" doesn't match its assertion; either rename the test to reflect that
it only checks registry hosts or add a token-related assertion: locate the test
using the it(...) string and the calls to policies.loadPreset and
policies.getPresetEndpoints, then either change the it(...) description to "ghcr
preset has registry endpoint" or extend the test to assert the token endpoint is
present (e.g., call the appropriate token endpoint extractor or inspect the
preset object returned by policies.loadPreset for the token host/URL and assert
it includes the expected token endpoint).
---
Nitpick comments:
In `@nemoclaw-blueprint/policies/presets/ghcr.yaml`:
- Around line 18-19: Replace the overly-broad POST rule "- allow: { method:
POST, path: "/**" }" with a scoped rule that only permits POST to the OCI v2
registry paths (for example "- allow: { method: POST, path: "/v2/**" }") so POST
actions (like initiating blob uploads) are limited to /v2/* endpoints; update
the corresponding entry in the YAML preset (the POST allow mapping) to use
"/v2/**" instead of "/**".
In `@test/policies.test.js`:
- Around line 12-27: The test contains a duplicated source of truth: the
hardcoded count 13 in the "returns all 13 presets" assertion and the explicit
expected array in the "returns expected preset names" test; replace the numeric
literal with a reference to the expected list length so they stay in sync by
deriving the count from the expected array (use the same expected array used in
the second test or move it to a shared variable) and assert that
policies.listPresets().length equals expected.length; reference
policies.listPresets, the presets/names variables and the expected array when
making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4e0809c3-c27c-42ee-8bf1-d35cf26a95b1
📒 Files selected for processing (5)
nemoclaw-blueprint/policies/presets/apt.yamlnemoclaw-blueprint/policies/presets/cargo.yamlnemoclaw-blueprint/policies/presets/ghcr.yamlnemoclaw-blueprint/policies/presets/go.yamltest/policies.test.js
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
43957ba to
ca5d144
Compare
Add network policy presets for Rust Cargo, Go modules, Debian/Ubuntu apt repositories, and GitHub Container Registry. Each follows the existing YAML schema with minimal required permissions (GET-only for package registries, GET+POST for auth token exchange on GHCR). Signed-off-by: Brian Taylor <brian@briantaylor.xyz> Signed-off-by: Brian Taylor <brian.taylor818@gmail.com>
- Scope storage.googleapis.com GET to /proxy-golang-org/** to prevent unrestricted access to arbitrary GCS content - Scope ghcr.io POST to /v2/** (OCI Distribution API) instead of /** - Derive preset count assertion from expected array to avoid dual source of truth - Fix ghcr test title to match actual assertions
…ethods - apt/cargo/go: restrict to GET only (read-only registries) - ghcr: GET globally + POST scoped to /v2/** (OCI distribution spec) - go: scope storage.googleapis.com to /golang/** path prefix - All presets now match the existing schema pattern (protocol, enforcement, tls, rules) used by npm/pypi/docker presets
6e6d8d4 to
18f91b7
Compare
…ng fix Package managers use CONNECT tunneling which breaks under tls: terminate. Align with ericksoa's PR #356 which switches npm/pypi to access: full for the same reason.
|
Thanks for adding the new policy presets for Cargo, Go modules, apt, and GHCR, this expands the coverage of our network policies and could be helpful for users working with these package ecosystems. |
Summary
access: fullwith binary restrictions, consistent with the upstream direction for package manager presets (see fix: repair pypi and npm policy presets for package manager traffic #356)Related to #19 — expanding preset coverage so additional package managers work inside the sandbox out of the box
Motivation
The sandbox ships with presets for npm, PyPI, Docker Hub, and a few messaging services, but developers using Rust, Go, Debian-based system packages, or GitHub Container Registry have no preset available. These 4 presets cover the most common gaps.
Test plan
Automated Tests
18 tests covering preset listing, endpoint extraction, YAML schema validation, and new preset endpoint verification.