fix(channels): apply network policy preset on channels add#3452
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR applies a channel's built-in policy preset immediately after gateway/registry registration in ChangesMessaging Channel Policy Preset Application
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
There was a problem hiding this comment.
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/channels-add-preset.test.ts`:
- Around line 178-180: Add an assertion that the "__RESULT__" marker exists
before attempting JSON.parse to avoid opaque failures when the spawned script
errors; specifically, right after computing marker (variable marker from
result.stdout.lastIndexOf("__RESULT__")), assert marker !== -1 (or use
assert.ok(marker >= 0, "...")) with a helpful message mirroring the
positive-case guard, then proceed to slice and JSON.parse into payload and keep
the existing assert.ok(!payload.error, ...).
🪄 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: cadf5b14-7915-4bed-80f1-8b99476cfb5c
📒 Files selected for processing (2)
src/lib/actions/sandbox/policy-channel.tstest/channels-add-preset.test.ts
…tps://github.com/NVIDIA/NemoClaw into fix/apply-preset-after-doing-channels-operations
Selective E2E Results — ✅ All requested jobs passedRun: 25855301592
|
…r-doing-channels-operations # Conflicts: # src/lib/actions/sandbox/policy-channel.ts
Selective E2E Results — ✅ All requested jobs passedRun: 25903976355
|
Summary
nemoclaw <sandbox> channels add <channel>registered the messaging bridge with the OpenShell gateway and triggered a rebuild, but never applied the channel's matching network policy preset. After the rebuild, the bridge booted with no allow-list entry for its upstream API host, so outbound traffic toapi.telegram.org/slack.com/discord.comwas denied by the SSRF engine and the channel silently failed to deliver messages. This wires the preset apply into thechannels addflow so it is captured in the rebuild backup manifest and restored by Step 5.5 ofrebuild.ts.Related Issue
Fixes #3437
Changes
applyChannelPresetIfAvailable(sandboxName, channelName)helper insrc/lib/actions/sandbox/policy-channel.ts— looks up the channel's matching built-in preset by name (e.g.telegram→telegram.yaml) and applies it idempotently viapolicies.applyPreset. No-op when the channel has no matching preset.addSandboxChannelbetweenapplyChannelAddToGatewayAndRegistryandpromptAndRebuild, so the preset is in place before the rebuild backup manifest is captured.nemoclaw <sandbox> policy-add <channel>recovery if the preset apply fails, mirroring rebuild Step 5.5's tolerance.telegram,slack,discord— allKNOWN_CHANNELSentries that ship a matching preset undernemoclaw-blueprint/policies/presets/.test/channels-add-preset.test.ts— stub-driven integration test mirroringtest/onboard-preset-diff.test.ts, asserts the ordering invariant (apply must precedepromptAndRebuild) for all three channels plus a negative no-matching-preset case.Testing
npx tsc -p tsconfig.src.json && npx vitest run --project cli test/channels-add-preset.test.tsExpected when the fix is in place (passing)
All 4 cases pass, confirming
policies.applyPreset(<sandbox>, <channel>)is invoked exactly once beforepromptAndRebuildfor each affected channel:Expected when the fix is reverted (catching the regression)
Comment out the
applyChannelPresetIfAvailable(...)call inaddSandboxChannel, rebuild dist, and rerun — the three positive cases fail withexpected applyPreset(...) exactly once; got [], proving the test catches the bug. The negative case continues to pass because it does not depend on the fix:Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Hung Le hple@nvidia.com
Summary by CodeRabbit
New Features
Tests