fix(goals): allow quoted-heredoc writes through the memory VFS#229
fix(goals): allow quoted-heredoc writes through the memory VFS#229khustup2 wants to merge 1 commit into
Conversation
Editing a goal/KPI body uses the documented multi-line form `cat > <path> <<'EOF' ... EOF`, but isSafe split the whole command on newlines and validated the heredoc *body* lines as command stages. Any prose body failed validation, so getShellCommand returned null, the hook never intercepted the write, and raw bash hit a nonexistent path — goal bodies were effectively uneditable via tooling. Strip quoted-heredoc bodies (`<<'EOF'`/`<<"EOF"`, which bash never expands) before validation: the body is inert data, while the command in front is still fully checked. Unquoted heredocs keep their body in validation, so `<<EOF ... $(...) ... EOF` style injection stays rejected.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR updates command validation in the ChangesHeredoc Handling in Command Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage ReportScope: files changed in this PR. Enforced threshold: 90% per metric (per file via
File Coverage — 1 file changed
Generated for commit c114d02. |
Problem
Editing a goal/KPI body through the Hivemind memory VFS uses the documented multi-line form:
…but this never worked. The
isSafegate in the pre-tool-use hook splits the entire command string on\nand validates each line as a command stage. The heredoc body lines (arbitrary goal prose) aren't safe builtins, soisSafereturnedfalse,getShellCommandreturnednull, the hook never intercepted the write, and raw bash hit a nonexistent path. Goal bodies were effectively uneditable via tooling — users had to abandon a goal and create a fresh one to "update" it.The downstream
deeplake-shell.jsalready handles heredoc create and overwrite (version-bump) correctly — verified end-to-end. This one gate was the entire blocker.Fix
src/hooks/memory-path-utils.ts: addstripHeredocBodies()and call it fromisSafe().<<'EOF'/<<"EOF"), which bash never expands, the body + closing delimiter are dropped before validation — the body is inert data. The command in front (cat > …) is still fully validated.<<EOF … $(rm -rf ~) … EOFis still rejected.Tests
isSafecases intests/claude-code/pre-tool-use-branches.test.ts(quoted accepted incl.<<-/ double-quote / backticks-in-body; unquoted$()and a non-builtin in front still rejected).Summary by CodeRabbit
Bug Fixes