Skip to content

fix(security): add --dry-run flag to policy-add for egress disclosure#1276

Merged
brandonpelfrey merged 3 commits intoNVIDIA:mainfrom
fdzdev:fix/policy-apply-disclosure
Apr 8, 2026
Merged

fix(security): add --dry-run flag to policy-add for egress disclosure#1276
brandonpelfrey merged 3 commits intoNVIDIA:mainfrom
fdzdev:fix/policy-apply-disclosure

Conversation

@fdzdev
Copy link
Copy Markdown
Contributor

@fdzdev fdzdev commented Apr 1, 2026

Summary

  • Add --dry-run flag to nemoclaw <name> policy-add that previews which endpoints a preset would open without applying (CWE-285, NVBUG 6002814)
  • In normal (non-dry-run) mode, endpoints are now shown before the Y/n confirmation prompt
  • No changes to non-interactive or onboard flows
  • Core policy approval gate depends on upstream OpenShell (openshell#584)

Test plan

  • nemoclaw <name> policy-add --dry-run — shows preset list, shows endpoints, prints "no changes applied"
  • nemoclaw <name> policy-add (normal) — shows endpoints before Y/n prompt, applies on Y
  • nemoclaw <name> policy-add → answer n — no changes applied
  • CLI help text shows --dry-run option
  • Existing CLI tests pass (25 total)

Signed-off-by: Facundo Fernandez facu.tha@gmail.com

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Added --dry-run flag to preview preset policy changes and list endpoints that would be opened; previews results without applying changes or prompting for confirmation.
    • CLI command now accepts and forwards flags to enable preview behavior.
  • Documentation

    • Updated CLI help to document the new --dry-run option.
  • Tests

    • Added/updated tests to verify dry-run output, endpoint preview, and that no changes are applied when --dry-run is used.

Add --dry-run flag to `nemoclaw <name> policy-add` that shows which
endpoints a preset would open without applying the policy change.
Also shows endpoints before the Y/n confirmation in normal mode.

This provides operator visibility into sandbox egress widening before
changes take effect (CWE-285, NVBUG 6002814). The core policy approval
gate depends on upstream OpenShell (openshell#584).

Signed-off-by: Facundo Fernandez <facu.tha@gmail.com>
Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 04a925db-4826-40c5-9d8d-08404a0ce448

📥 Commits

Reviewing files that changed from the base of the PR and between 8a7ce81 and fe7981b.

📒 Files selected for processing (2)
  • bin/nemoclaw.js
  • test/policies.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/nemoclaw.js

📝 Walkthrough

Walkthrough

sandboxPolicyAdd now accepts CLI args and supports --dry-run, which loads and previews preset endpoints without applying changes; normal flow still prompts and applies the preset. Tests updated to exercise --dry-run and to stub preset-loading and endpoint-preview behavior.

Changes

Cohort / File(s) Summary
CLI / Command
bin/nemoclaw.js
sandboxPolicyAdd(sandboxName, args = []) added; detects --dry-run via args.includes("--dry-run"); loads preset with policies.loadPreset and derives endpoints with policies.getPresetEndpoints for preview; prints dry-run message and returns early when present; dispatcher forwards actionArgs; help text updated to document --dry-run.
Tests
test/policies.test.js
runPolicyAdd accepts extraArgs and injects into spawned process argv; test stub for policies adds loadPreset and getPresetEndpoints for pypi; test stdout format changed to include __CALLS__ sentinel; new test asserts --dry-run produces endpoint preview and no prompt or apply calls.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI (nemoclaw)
    participant Policies as policies module
    participant Prompt as user prompt
    participant Stdout as stdout/log

    CLI->>Policies: policies.loadPreset(presetName)
    CLI->>Policies: policies.getPresetEndpoints(preset)
    Policies-->>CLI: preset, endpoints
    CLI->>Stdout: print endpoint preview
    alt --dry-run present
        CLI->>Stdout: print "--dry-run: no changes applied."
        CLI-->>CLI: return (no prompt, no apply)
    else normal flow
        CLI->>Prompt: ask for confirmation
        Prompt-->>CLI: user confirms
        CLI->>Policies: policies.applyPreset(preset)
        Policies-->>Stdout: report apply results
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nudge the preset, peek at each end,
A quiet preview — no changes to send,
With gentle hops I list what would be,
A dry-run dance, cautious and free,
The rabbit smiles: review before mend.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a --dry-run flag to policy-add for endpoint disclosure, which is the primary objective of the pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@bin/nemoclaw.js`:
- Around line 689-700: When policies.loadPreset(answer) returns null/undefined
(presetContent falsy), the script currently returns silently; change the
behavior in the block using loadPreset/presetContent so that if presetContent is
falsy you print a clear error (e.g., "Preset '{answer}' not found" or "Invalid
preset: {answer}") to stderr or console.error and exit with a non-zero code (or
return an error status) instead of silently returning; ensure this check happens
before calling policies.getPresetEndpoints and preserves the existing dryRun
handling and messaging flow.
🪄 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: b50856a3-0a48-49bc-b299-b63a3b5680a2

📥 Commits

Reviewing files that changed from the base of the PR and between 2804b74 and 9893f04.

📒 Files selected for processing (1)
  • bin/nemoclaw.js

Comment thread bin/nemoclaw.js
Comment on lines +689 to +700
const presetContent = policies.loadPreset(answer);
if (!presetContent) return;

const endpoints = policies.getPresetEndpoints(presetContent);
if (endpoints.length > 0) {
console.log(` Endpoints that would be opened: ${endpoints.join(", ")}`);
}

if (dryRun) {
console.log(" --dry-run: no changes applied.");
return;
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Apr 1, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Silent failure when preset name is invalid provides no user feedback.

When loadPreset returns null (nonexistent or invalid preset name), the function silently returns without informing the user. This is confusing UX—the user won't know why nothing happened.

Proposed fix to add error feedback
   const presetContent = policies.loadPreset(answer);
-  if (!presetContent) return;
+  if (!presetContent) {
+    console.error(`  Unknown preset: ${answer}`);
+    return;
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const presetContent = policies.loadPreset(answer);
if (!presetContent) return;
const endpoints = policies.getPresetEndpoints(presetContent);
if (endpoints.length > 0) {
console.log(` Endpoints that would be opened: ${endpoints.join(", ")}`);
}
if (dryRun) {
console.log(" --dry-run: no changes applied.");
return;
}
const presetContent = policies.loadPreset(answer);
if (!presetContent) {
console.error(` Unknown preset: ${answer}`);
return;
}
const endpoints = policies.getPresetEndpoints(presetContent);
if (endpoints.length > 0) {
console.log(` Endpoints that would be opened: ${endpoints.join(", ")}`);
}
if (dryRun) {
console.log(" --dry-run: no changes applied.");
return;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/nemoclaw.js` around lines 689 - 700, When policies.loadPreset(answer)
returns null/undefined (presetContent falsy), the script currently returns
silently; change the behavior in the block using loadPreset/presetContent so
that if presetContent is falsy you print a clear error (e.g., "Preset '{answer}'
not found" or "Invalid preset: {answer}") to stderr or console.error and exit
with a non-zero code (or return an error status) instead of silently returning;
ensure this check happens before calling policies.getPresetEndpoints and
preserves the existing dryRun handling and messaging flow.

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.

@fdzdev Let's add a warning that no preset was found by that name

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@wscurran wscurran added security Something isn't secure priority: high Important issue that should be resolved in the next release NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). labels Apr 3, 2026
@wscurran
Copy link
Copy Markdown
Contributor

wscurran commented Apr 3, 2026

✨ Thanks for submitting this pull request, which proposes a way to improve security transparency in the CLI's policy management flow by adding a --dry-run option and better endpoint visibility.

Copy link
Copy Markdown
Collaborator

@brandonpelfrey brandonpelfrey left a comment

Choose a reason for hiding this comment

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

Automated testing in VM

@brandonpelfrey brandonpelfrey merged commit 117da53 into NVIDIA:main Apr 8, 2026
3 checks passed
miyoungc added a commit that referenced this pull request Apr 9, 2026
## Summary
- Document `nemoclaw credentials list` and `nemoclaw credentials reset`
commands in commands reference (#1597)
- Add `--dry-run` flag documentation for `policy-add` (#1276)
- Update policy presets table: remove `docker` (#1647), add `brave` and
`brew`, update HuggingFace endpoint (#1540)
- Document `NEMOCLAW_LOCAL_INFERENCE_TIMEOUT` env var for local
providers (#1620)
- Document `NEMOCLAW_PROXY_HOST`/`NEMOCLAW_PROXY_PORT` env vars (#1563)
- Add troubleshooting entries for Docker group permissions (#1614),
sandbox survival after gateway restart (#1587), and proxy configuration
- Regenerate `nemoclaw-user-*` skills from updated docs

## Test plan
- [x] `make docs` builds without warnings
- [x] All pre-commit and pre-push hooks pass
- [ ] Verify rendered pages in docs site preview

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added `nemoclaw credentials list` command to display stored credential
names
* Added `nemoclaw credentials reset <KEY>` command with `--yes` flag to
remove credentials
  * Added `--dry-run` flag for policy-add to preview endpoint changes
  * New policy presets: `brave` and `brew`
* New configuration options: `NEMOCLAW_LOCAL_INFERENCE_TIMEOUT`,
`NEMOCLAW_PROXY_HOST`, and `NEMOCLAW_PROXY_PORT`

* **Documentation**
* Expanded troubleshooting guides for Docker permissions, sandbox
connectivity, local inference timeouts, and proxy configuration

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
…NVIDIA#1276)

## Summary

- Add `--dry-run` flag to `nemoclaw <name> policy-add` that previews
which endpoints a preset would open without applying (CWE-285, NVBUG
6002814)
- In normal (non-dry-run) mode, endpoints are now shown before the Y/n
confirmation prompt
- No changes to non-interactive or onboard flows
- Core policy approval gate depends on upstream OpenShell
(openshell#584)

## Test plan

- [ ] `nemoclaw <name> policy-add --dry-run` — shows preset list, shows
endpoints, prints "no changes applied"
- [ ] `nemoclaw <name> policy-add` (normal) — shows endpoints before Y/n
prompt, applies on Y
- [ ] `nemoclaw <name> policy-add` → answer `n` — no changes applied
- [ ] CLI help text shows `--dry-run` option
- [ ] Existing CLI tests pass (25 total)

Signed-off-by: Facundo Fernandez <facu.tha@gmail.com>

Made with [Cursor](https://cursor.com)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added `--dry-run` flag to preview preset policy changes and list
endpoints that would be opened; previews results without applying
changes or prompting for confirmation.
* CLI command now accepts and forwards flags to enable preview behavior.

* **Documentation**
  * Updated CLI help to document the new `--dry-run` option.

* **Tests**
* Added/updated tests to verify dry-run output, endpoint preview, and
that no changes are applied when `--dry-run` is used.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Facundo Fernandez <facu.tha@gmail.com>
Co-authored-by: Brandon Pelfrey <bpelfrey@nvidia.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
## Summary
- Document `nemoclaw credentials list` and `nemoclaw credentials reset`
commands in commands reference (NVIDIA#1597)
- Add `--dry-run` flag documentation for `policy-add` (NVIDIA#1276)
- Update policy presets table: remove `docker` (NVIDIA#1647), add `brave` and
`brew`, update HuggingFace endpoint (NVIDIA#1540)
- Document `NEMOCLAW_LOCAL_INFERENCE_TIMEOUT` env var for local
providers (NVIDIA#1620)
- Document `NEMOCLAW_PROXY_HOST`/`NEMOCLAW_PROXY_PORT` env vars (NVIDIA#1563)
- Add troubleshooting entries for Docker group permissions (NVIDIA#1614),
sandbox survival after gateway restart (NVIDIA#1587), and proxy configuration
- Regenerate `nemoclaw-user-*` skills from updated docs

## Test plan
- [x] `make docs` builds without warnings
- [x] All pre-commit and pre-push hooks pass
- [ ] Verify rendered pages in docs site preview

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added `nemoclaw credentials list` command to display stored credential
names
* Added `nemoclaw credentials reset <KEY>` command with `--yes` flag to
remove credentials
  * Added `--dry-run` flag for policy-add to preview endpoint changes
  * New policy presets: `brave` and `brew`
* New configuration options: `NEMOCLAW_LOCAL_INFERENCE_TIMEOUT`,
`NEMOCLAW_PROXY_HOST`, and `NEMOCLAW_PROXY_PORT`

* **Documentation**
* Expanded troubleshooting guides for Docker permissions, sandbox
connectivity, local inference timeouts, and proxy configuration

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). priority: high Important issue that should be resolved in the next release security Something isn't secure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants