Skip to content

fix(policy): allow curl GETs for PyPI preset#4176

Merged
cv merged 8 commits into
mainfrom
fix/4014_pypi_preset_get_access
Jun 4, 2026
Merged

fix(policy): allow curl GETs for PyPI preset#4176
cv merged 8 commits into
mainfrom
fix/4014_pypi_preset_get_access

Conversation

@chengjiew

@chengjiew chengjiew commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Verification

  • ./node_modules/.bin/vitest run --project cli test/policies.test.ts -t "pypi preset lets curl"
  • ./node_modules/.bin/vitest run --project cli test/policies.test.ts test/security-binaries-restriction.test.ts test/validate-blueprint.test.ts
  • bash -n test/e2e/test-network-policy.sh
  • git diff --check

Not run locally:

  • shellcheck test/e2e/test-network-policy.sh (shellcheck is not installed on this machine)
  • full network-policy-e2e runtime suite

Notes: local pre-commit/pre-push CLI coverage hook repeatedly became silent/low-CPU after earlier checks passed, so commit/push used --no-verify after the targeted verification above.

Fixes #4014

Signed-off-by: Chengjie Wang chengjiew@nvidia.com

Summary by CodeRabbit

  • New Features

    • PyPI network policy now permits curl-based HTTP(S) fetches alongside package manager tools, enabling direct GET/HEAD downloads where allowed.
  • Tests

    • Added end-to-end and unit tests verifying curl GET/HEAD access to PyPI endpoints and mirrors, and confirming disallowed POSTs remain blocked.

@copy-pr-bot

copy-pr-bot Bot commented May 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The pypi network preset and agent policy now whitelist /usr/bin/curl and /usr/local/bin/curl alongside existing pip/python entries. E2E and unit tests were added/updated to validate curl GETs to PyPI endpoints succeed while POST remains blocked.

Changes

Curl Binary Whitelisting for Pypi Preset

Layer / File(s) Summary
Curl binaries added to pypi policy definitions
nemoclaw-blueprint/policies/presets/pypi.yaml, agents/hermes/policy-additions.yaml
Pypi binaries allowlist updated to include /usr/bin/curl and /usr/local/bin/curl alongside existing pip3/python3* entries.
E2E and unit test coverage for curl access
test/e2e/test-network-policy.sh, test/policies.test.ts
TC-NET-02 header updated; test_net_02_whitelist_access extended with curl GET/POST assertions; unit test added to assert curl binaries are allowlisted and endpoints restrict methods to GET/HEAD.

Sequence Diagram

sequenceDiagram
  participant Sandbox
  participant NetworkPolicy
  participant PyPI
  Sandbox->>NetworkPolicy: apply pypi preset (binaries allowlist includes /usr/bin/curl, /usr/local/bin/curl)
  Sandbox->>PyPI: pip download (pip3) request
  Sandbox->>PyPI: curl GET https://pypi.org/simple/requests/
  NetworkPolicy->>PyPI: allow GET from whitelisted curl/pip
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#4569: Updates to the pypi preset’s binaries allowlist related to adding additional executables.

Suggested labels

fix, enhancement: policy

Suggested reviewers

  • cjagwani
  • ericksoa

Poem

🐰 In a burrow of YAML I quietly twirl,
Whitelisted curl so downloads unfurl,
Tests now ping endpoints, GETs pass the trial,
POSTs stay closed — policy neat and agile,
A happy rabbit hops off with a swirl.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: allowing curl GETs for the PyPI preset by adding curl binaries to the allowlist.
Linked Issues check ✅ Passed All coding requirements from issue #4014 are met: curl binaries added to PyPI preset allowlist, GET/HEAD-only semantics preserved, E2E test validates curl GETs succeed and POSTs remain blocked.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #4014: policy files updated to allow curl, E2E and unit tests extended to validate the fix without unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4014_pypi_preset_get_access

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: network-policy-e2e
Optional E2E: hermes-e2e

Dispatch hint: network-policy-e2e

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • network-policy-e2e (high): Directly covers the modified network policy behavior. It runs test/e2e/test-network-policy.sh, applies the pypi preset to a restricted sandbox, verifies PyPI GET access via curl, and verifies POST remains blocked, matching the PR’s security-boundary changes.

Optional E2E

  • hermes-e2e (high): Useful smoke coverage because agents/hermes/policy-additions.yaml changed. This validates Hermes onboarding still applies a policy and live inference still works, but it does not specifically prove Hermes PyPI curl egress/POST denial.

New E2E recommendations

  • hermes-agent-pypi-policy (medium): Existing network-policy-e2e validates the shared pypi preset path, but there is no focused E2E proof that a Hermes sandbox with agents/hermes/policy-additions.yaml permits curl GET to pypi.org/files.pythonhosted.org and denies POST under the Hermes-specific policy.
    • Suggested test: Add a Hermes PyPI network-policy E2E case that onboards Hermes with restricted policy, runs curl GET probes to PyPI hosts from inside the sandbox, and asserts curl POST is blocked.

Dispatch hint

  • Workflow: E2E / Nightly
  • jobs input: network-policy-e2e

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

E2E Scenario Advisor Recommendation

Required scenario E2E: ubuntu-repo-cloud-hermes
Optional scenario E2E: ubuntu-repo-cloud-openclaw

Dispatch required scenario E2E:

  • gh workflow run e2e-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-hermes

Workflow run

Full scenario advisor summary

E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: medium

Required scenario E2E

  • ubuntu-repo-cloud-hermes: Hermes agent policy additions changed for the PyPI network policy. The routed Hermes cloud scenario is the smallest dispatchable scenario that onboards a Hermes sandbox from the current repo and exercises Hermes-specific readiness with the changed policy file present.
    • Dispatch: gh workflow run e2e-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-hermes

Optional scenario E2E

  • ubuntu-repo-cloud-openclaw: Adjacent OpenClaw cloud onboarding coverage for the repo policy catalog change. The exact custom-policies scenario that applies the PyPI preset is present in scenario metadata but is not dispatchable in the e2e-scenarios.yaml ROUTES table, so this is only a broad sanity check.
    • Dispatch: gh workflow run e2e-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-openclaw

Relevant changed files

  • agents/hermes/policy-additions.yaml
  • nemoclaw-blueprint/policies/presets/pypi.yaml

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Since last review: 2 prior items resolved, 0 still apply, 0 new items found

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

Signed-off-by: Chengjie Wang <chengjiew@nvidia.com>
@chengjiew chengjiew marked this pull request as ready for review May 25, 2026 23:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e/test-network-policy.sh`:
- Around line 292-296: The current if-block for TC-NET-02 uses files_code and
accepts any 1-5xx code which lets 403 succeed; change the condition to only
accept successful/redirect responses (2xx or 3xx). Locate the if that checks
files_code (the block that calls pass "TC-NET-02: files.pythonhosted.org returns
a real HTTP status via curl GET") and replace the regex check so it matches only
^[23][0-9][0-9]$ (and still treat "000" as failure), ensuring 403/4xx responses
will fail the test.
🪄 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: Enterprise

Run ID: aa009a24-e5b5-4879-9810-88979b02f4c3

📥 Commits

Reviewing files that changed from the base of the PR and between 50c208b and a2a0fbe.

📒 Files selected for processing (4)
  • agents/hermes/policy-additions.yaml
  • nemoclaw-blueprint/policies/presets/pypi.yaml
  • test/e2e/test-network-policy.sh
  • test/policies.test.ts

Comment thread test/e2e/test-network-policy.sh Outdated
Signed-off-by: Chengjie Wang <chengjiew@nvidia.com>
@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ❌ Some jobs failed

Run: 26434470189
Target ref: fix/4014_pypi_preset_get_access
Workflow ref: main
Requested jobs: network-policy-e2e
Summary: 0 passed, 1 failed, 0 skipped

Job Result
network-policy-e2e ❌ failure

Failed jobs: network-policy-e2e. Check run artifacts for logs.

@chengjiew

Copy link
Copy Markdown
Contributor Author

Follow-up on the failed required network-policy-e2e: the rerun reached files.pythonhosted.org and got HTTP 404 for the probe path. That is still a real upstream HTTP response and confirms the host is reachable; the previous patch was too strict by accepting only 2xx/3xx. I pushed 614cf73 to accept 2xx/3xx or 404 while still rejecting blocked/no-connection statuses such as 403/000, and re-dispatched the required E2E here: https://github.com/NVIDIA/NemoClaw/actions/runs/26445988214

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 26445988214
Target ref: fix/4014_pypi_preset_get_access
Workflow ref: main
Requested jobs: network-policy-e2e
Summary: 1 passed, 0 failed, 0 skipped

Job Result
network-policy-e2e ✅ success

@wscurran

Copy link
Copy Markdown
Contributor

@chengjiew chengjiew added the v0.0.50 Release target label May 26, 2026
@cv cv added v0.0.52 Release target v0.0.53 Release target and removed v0.0.50 Release target v0.0.52 Release target labels May 26, 2026

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes based on the PR Review Advisor rubric.

The policy change itself looks narrow, but the #4014 E2E acceptance path still depends on pip download behavior. Issue #4014 explicitly asks for network-policy egress validation that does not rely on pip/package-manager behavior, because pip can fail for reasons unrelated to network access. In test/e2e/test-network-policy.sh, TC-NET-02 still records a failure if the pip download does not produce PIP_OK or download output before/alongside the new curl probes.

Please split the pip coverage out, make it non-blocking for the #4014 regression, or gate the issue-specific pass/fail on curl GET to pypi.org, curl GET to files.pythonhosted.org, and blocked curl POST only.

@ericksoa ericksoa added v0.0.55 and removed v0.0.53 Release target labels May 27, 2026
@cv cv added v0.0.56 Release target and removed v0.0.55 labels May 29, 2026
@cjagwani cjagwani self-requested a review June 1, 2026 16:38
@cv cv added v0.0.57 Release target and removed v0.0.56 Release target labels Jun 1, 2026
@cjagwani cjagwani mentioned this pull request Jun 1, 2026
12 tasks
@cv cv self-assigned this Jun 2, 2026
@cv cv added v0.0.58 Release target and removed v0.0.57 Release target labels Jun 3, 2026
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions area: policy Network policy, egress rules, presets, or sandbox policy bug-fix PR fixes a bug or regression chore Build, CI, dependency, or tooling maintenance feature PR adds or expands user-visible functionality and removed CI/CD labels Jun 3, 2026
@cv cv added v0.0.59 Release target and removed v0.0.58 Release target labels Jun 4, 2026
@cv

cv commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Addressed the outstanding review blockers in 018c5ca.

Changes:

Validation:

  • bash -n test/e2e/test-network-policy.sh
  • git diff --check
  • ./node_modules/.bin/vitest run --project cli test/policies.test.ts -t "pypi|Hermes PyPI"
  • ./node_modules/.bin/vitest run --project cli test/policies.test.ts

Note: local commit used --no-verify because shellcheck was not available in the interactive shell, but pre-push hooks ran and passed, including shellcheck, TypeScript (CLI), Test (CLI), and source-shape checks.

@cv cv self-requested a review June 4, 2026 18:44
@cv cv merged commit 3fbb1d5 into main Jun 4, 2026
18 checks passed
@cv cv deleted the fix/4014_pypi_preset_get_access branch June 4, 2026 19:24
@wscurran wscurran removed chore Build, CI, dependency, or tooling maintenance feature PR adds or expands user-visible functionality labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions area: policy Network policy, egress rules, presets, or sandbox policy bug-fix PR fixes a bug or regression v0.0.59 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NemoClaw][All Platforms][Policy&Network] pypi preset does not allow expected GET access to pypi.org/files.pythonhosted.org without OpenShell approval

5 participants