fix(sandbox): make rlimit helper posix-sh safe - #5840
Conversation
|
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:
📝 WalkthroughWalkthroughThe sandbox rlimit library now probes resource-flag support, uses ChangesSandbox RLIMIT handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most covered files.
Updated |
PR Review Advisor — Changes requestedMerge posture: Do not merge yet Action checklist
Findings index
Review findings by urgency: 0 required fixes, 2 items to resolve/justify, 0 in-scope improvements
|
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: Dispatch required Vitest E2E scenarios:
Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
Relevant changed files
|
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/sandbox-rlimit-hooks.test.ts`:
- Around line 171-182: The POSIX shell probe in expectRlimitLibIsPosixShSafe can
continue past a failed source, missing harden_resource_limits function, or
failing verify_resource_limits and still print ok; update the probe so it stops
on any non-zero command before the success print, using the existing probe
assembly in expectRlimitLibIsPosixShSafe to ensure failures are surfaced
correctly.
🪄 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: 59c634de-8ab2-44e9-928b-1dee529c8858
📒 Files selected for processing (3)
scripts/lib/sandbox-rlimits.shtest/sandbox-init.test.tstest/sandbox-rlimit-hooks.test.ts
Selective E2E Results — ✅ All requested jobs passedRun: 28224381191
|
Selective E2E Results — ✅ All requested jobs passedRun: 28225024844
|
Selective E2E Results — ✅ All requested jobs passedRun: 28225749543
|
Selective E2E Results — ✅ All requested jobs passedRun: 28226596253
|
|
Addressing PR Review Advisor warnings PRA-1/PRA-2:
Given the above, I believe the remaining PRA items are justified by the code comment plus regression tests. |
<!-- markdownlint-disable MD041 --> ## Summary Make the shared sandbox rlimit helper safe to source from POSIX `/bin/sh` profile hooks. This prevents `openshell sandbox exec ... sh -lc ...` probes from emitting bash-only `builtin ulimit` warnings while preserving the shadowed-`ulimit` bypass in bash. ## Changes - Switch `scripts/lib/sandbox-rlimits.sh` from bash-only `builtin ulimit` calls to a POSIX-safe `command ulimit` wrapper. - Skip verification for resource-limit flags unsupported by the active shell, such as `ulimit -u` under dash, instead of reporting `unknown` limits. - Add a POSIX-sh regression test and update shadowed-`ulimit` tests to cover the new helper behavior. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates <!-- Check all that apply. For any "covered by existing tests", "not applicable", or waiver entry, add a brief justification on the same line or in the Changes section. --> - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: internal sandbox rlimit/profile-hook compatibility fix; no user-facing command or configuration change. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: author self-review; change is limited to the sandbox rlimit helper, keeps the shadowed-`ulimit` hardening test, and passes shellcheck/prek plus targeted tests. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification <!-- Check each item you ran and confirmed. Leave unchecked items you skipped. Doc-only changes do not require npm test unless you ran it. --> - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Git hooks passed during commit and push, or `npx prek run --from-ref main --to-ref HEAD` passes - [x] Targeted tests pass for changed behavior - [ ] Full `npm test` passes (broad runtime changes only) - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off is required in this PR description, and every commit must appear as Verified in GitHub. Run: git config user.name && git config user.email --> Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved resource-limit hardening and verification for POSIX `sh`, especially when `ulimit` is shadowed by shell functions. * Resource-limit checks now detect supported `ulimit` flags and validate effective numeric limits more reliably, reducing incorrect verification failures. * **Tests** * Expanded POSIX `sh` test coverage for rlimit hooks and sandbox hardening, including bypassing shadowed `ulimit`. * Added/adjusted scenarios to confirm unsafe or unbounded `nofile` targets are rejected. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Make the shared sandbox rlimit helper safe to source from POSIX
/bin/shprofile hooks. This preventsopenshell sandbox exec ... sh -lc ...probes from emitting bash-onlybuiltin ulimitwarnings while preserving the shadowed-ulimitbypass in bash.Changes
scripts/lib/sandbox-rlimits.shfrom bash-onlybuiltin ulimitcalls to a POSIX-safecommand ulimitwrapper.ulimit -uunder dash, instead of reportingunknownlimits.ulimittests to cover the new helper behavior.Type of Change
Quality Gates
ulimithardening test, and passes shellcheck/prek plus targeted tests.Verification
Verifiedin GitHubnpx prek run --from-ref main --to-ref HEADpassesnpm testpasses (broad runtime changes only)npm run docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
sh, especially whenulimitis shadowed by shell functions.ulimitflags and validate effective numeric limits more reliably, reducing incorrect verification failures.shtest coverage for rlimit hooks and sandbox hardening, including bypassing shadowedulimit.nofiletargets are rejected.