refactor(openclaw): share device approval policy#4788
Conversation
|
Warning Review limit reached
More reviews will be available in 21 minutes and 14 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR extracts device approval logic into a shared Python policy module and wires it into the embedded shell watcher and the sandbox in-sandbox approval pass, stages and packages the module for runtime, and extends tests to validate decision behavior and tamper-resistance. ChangesDevice Approval Policy Externalization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 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 unit tests (beta)
Comment |
PR Review AdvisorFindings: 0 needs attention, 4 worth checking, 0 nice ideas Review findings🛠️ Needs attention
🔎 Worth checking
🌱 Nice ideas
Consider writing more tests for
Since last review detailsCurrent findings:
This is an automated advisory review. A human maintainer must make the final merge decision. |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
E2E Scenario Advisor RecommendationRequired scenario E2E: Dispatch required scenario E2E:
Full scenario advisor summaryE2E Scenario AdvisorBase: Required scenario E2E
Optional scenario E2E
Relevant changed files
|
…-helper-ff # Conflicts: # scripts/nemoclaw-start.sh # src/lib/actions/sandbox/connect.ts # test/sandbox-connect-inference.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
Dockerfile (1)
403-421: Please run the boot-path E2Es for this image change.This bakes a new runtime asset that the sandbox entrypoint now executes during device approval, so unit coverage alone will miss image/boot regressions. I’d run the targeted
sandbox-survival-e2e,sandbox-operations-e2e,cloud-e2e,openclaw-slack-pairing-e2e,hermes-e2e,rebuild-openclaw-e2e, andopenclaw-tui-chat-correlation-e2ejobs before merge. As per coding guidelines,Dockerfilechanges are only testable with a real container build, andscripts/nemoclaw-start.shchanges affect every sandbox boot and are invisible to unit tests.🤖 Prompt for 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. In `@Dockerfile` around lines 403 - 421, This change adds runtime files (notably the new /usr/local/bin/nemoclaw-start entrypoint and files under /usr/local/lib/nemoclaw/) that affect sandbox boot-time behavior, so before merging build the updated Docker image and run the boot-path E2E suites: sandbox-survival-e2e, sandbox-operations-e2e, cloud-e2e, openclaw-slack-pairing-e2e, hermes-e2e, rebuild-openclaw-e2e, and openclaw-tui-chat-correlation-e2e against the built image (verify sandbox boots, device approval flow using scripts/nemoclaw-start.sh and openclaw_device_approval_policy.py, and that preloads under /usr/local/lib/nemoclaw/preloads load correctly); fix any failures, then re-run the same E2Es until green before merging.Source: Coding guidelines
🤖 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 `@scripts/nemoclaw-start.sh`:
- Around line 1737-1749: The loader currently only rejects group/other writable
helpers but must also reject files that are owner-writable by the current
sandbox user; inside load_approval_policy, after obtaining st = os.stat(path)
use st.st_uid and compare to os.geteuid(), and if st.st_uid == os.geteuid() and
st.st_mode & stat.S_IWUSR raise a RuntimeError (similar to the existing
group/other check) so any helper writable by the effective sandbox UID is
rejected; keep the existing stat.S_IWGRP|stat.S_IWOTH check and then proceed to
import as before (refer to load_approval_policy, APPROVAL_POLICY_FILE,
approval_request_decision, gateway_approval_env).
---
Nitpick comments:
In `@Dockerfile`:
- Around line 403-421: This change adds runtime files (notably the new
/usr/local/bin/nemoclaw-start entrypoint and files under
/usr/local/lib/nemoclaw/) that affect sandbox boot-time behavior, so before
merging build the updated Docker image and run the boot-path E2E suites:
sandbox-survival-e2e, sandbox-operations-e2e, cloud-e2e,
openclaw-slack-pairing-e2e, hermes-e2e, rebuild-openclaw-e2e, and
openclaw-tui-chat-correlation-e2e against the built image (verify sandbox boots,
device approval flow using scripts/nemoclaw-start.sh and
openclaw_device_approval_policy.py, and that preloads under
/usr/local/lib/nemoclaw/preloads load correctly); fix any failures, then re-run
the same E2Es until green before merging.
🪄 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: 3c759f01-3daf-4710-8dcd-fdd6cfb2bbc5
📒 Files selected for processing (8)
Dockerfilescripts/lib/openclaw_device_approval_policy.pyscripts/nemoclaw-start.shsrc/lib/actions/sandbox/connect.tssrc/lib/sandbox/build-context.tstest/nemoclaw-start.test.tstest/sandbox-build-context.test.tstest/sandbox-connect-inference.test.ts
Selective E2E Results — ✅ All requested jobs passedRun: 26985744598
|
Selective E2E Results — ✅ All requested jobs passedRun: 26986068886
|
Selective E2E Results — ✅ All requested jobs passedRun: 26986310753
|
Selective E2E Results — ✅ All requested jobs passedRun: 26986708337
|
Summary
Share the OpenClaw device approval allowlist/scope policy between the startup auto-pair watcher and the connect-time approval pass. This keeps the #4786 compatibility shim fail-closed in one place while still injecting the helper into existing sandboxes during
connect.Related Issue
Refs #4462, #4263. Stacked on #4786.
Changes
scripts/lib/openclaw_device_approval_policy.pyas the shared policy helper for allowed clients, modes, scopes, malformed scope rejection, and gateway-env stripping.nemoclaw-start.shand inject the same helper into/tmpfor the connect-time approval pass.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesnpm run docsbuilds without warnings (doc changes only)Additional focused checks run:
npm run build:clinpm run typecheck:clinpm test -- --run test/nemoclaw-start.test.ts test/sandbox-connect-inference.test.ts test/sandbox-build-context.test.tspython3 -m py_compile scripts/lib/openclaw_device_approval_policy.pybash -n scripts/nemoclaw-start.shSkipped/blocked:
npx prek run --files ...andnode_modules/.bin/prek --versionboth failed before hooks ran withError fetching release: self-signed certificate in certificate chain.shellcheck scripts/nemoclaw-start.shwas not available in this environment (shellcheck: command not found).Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
New Features
Chores
Tests