fix(sandbox): make workspace template seeding shell-serializable#3787
fix(sandbox): make workspace template seeding shell-serializable#3787gauravprasadgp wants to merge 17 commits into
Conversation
|
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)
📝 WalkthroughWalkthroughThe PR refactors the skip-bootstrap validation in ChangesSkip bootstrap check refactoring and testing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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 |
|
@gauravprasadgp mind addressing the failing checks, please? |
Done @cv please proceed. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/nemoclaw-start-workspace-template-seeding.test.ts (1)
13-19: 💤 Low valueStatic analysis flagged potential ReDoS risk from regex variable interpolation.
The regex construction on line 14 uses the
nameparameter directly, which static analysis flagged as a potential Regular Expression Denial of Service (ReDoS) vector. In this test file,nameis always the hardcoded string"seed_default_workspace_templates"(line 29), making this a false positive in practice.However, as a defensive measure, consider escaping special regex characters in the
nameparameter:🛡️ Optional defensive fix
function extractShellFunctionFromSource(src: string, name: string): string { - const match = src.match(new RegExp(`${name}\\(\\) \\{([\\s\\S]*?)^\\}`, "m")); + const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const match = src.match(new RegExp(`${escapedName}\\(\\) \\{([\\s\\S]*?)^\\}`, "m")); if (!match) {🤖 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 `@test/nemoclaw-start-workspace-template-seeding.test.ts` around lines 13 - 19, The test's extractShellFunctionFromSource function interpolates the name parameter directly into a RegExp causing a potential ReDoS; fix it by escaping regex-special characters in name before building the RegExp (e.g., transform name with a safe escape like replace(/[.*+?^${}()|[\]\\]/g, '\\$&') so the generated pattern treats the function name literally) and then use the escapedName in new RegExp; refer to function extractShellFunctionFromSource and the name variable when making this change.Source: Linters/SAST tools
🤖 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.
Nitpick comments:
In `@test/nemoclaw-start-workspace-template-seeding.test.ts`:
- Around line 13-19: The test's extractShellFunctionFromSource function
interpolates the name parameter directly into a RegExp causing a potential
ReDoS; fix it by escaping regex-special characters in name before building the
RegExp (e.g., transform name with a safe escape like
replace(/[.*+?^${}()|[\]\\]/g, '\\$&') so the generated pattern treats the
function name literally) and then use the escapedName in new RegExp; refer to
function extractShellFunctionFromSource and the name variable when making this
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d39592dc-234a-4276-a9ba-7521a60ebf1c
📒 Files selected for processing (1)
test/nemoclaw-start-workspace-template-seeding.test.ts
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the branch is 96%. Coverage data for the branch is not yet available. Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the branch is 44%. Coverage data for the branch is not yet available. Show a code coverage summary of the most covered files.
Updated |
Summary
Fixes
seed_default_workspace_templatesstartup failures caused by a heredoc inside anifblock failing to survive thedeclare -f/bash -cround-trip. The skip-bootstrap check now usesnode -e, keeping the serialized shell function flat and parseable.Related Issue
Fixes #NNN
Changes
seed_default_workspace_templateswith anode -esnippet.agents.defaults.skipBootstrapistrue.declare -fandbash -c, then verifies template seeding still works.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Focused verification run:
bash -n scripts/nemoclaw-start.shnpm test -- test/nemoclaw-start.test.ts -t "round-trips seed_default_workspace_templates"git diff --check -- scripts/nemoclaw-start.sh test/nemoclaw-start.test.tsSigned-off-by: gauravprasad prasadgaurav559@gmail.com
Summary by CodeRabbit
Refactor
Tests