fix(recipes): replace quoted heredocs with direct env-var assignment (skwaq#469)#4245
fix(recipes): replace quoted heredocs with direct env-var assignment (skwaq#469)#4245
Conversation
…(skwaq#469) The recipe runner 0.3.4 does INLINE substitution for quoted heredocs (<<'EOF'). If a template variable value (e.g. final_requirements from step-02c) contains the heredoc terminator string on its own line, the heredoc terminates early. When the content remaining after the early termination has an odd number of single quotes, bash raises: /bin/bash: -c: line N: unexpected EOF while looking for matching \' This is the exact failure in skwaq issue #469, which blocked every benchmark and PR workflow that went through default-workflow/smart- orchestrator. Root cause verification: recipe-runner-rs with value containing 'EOFREQS\nit\'s content' → /bin/bash: -c: line 5: unexpected EOF while looking for matching `' Fix: replace all four affected quoted-heredoc captures in - step-03-create-issue ({{task_description}}, {{final_requirements}}) - step-03b-extract-issue-number ({{issue_creation}}, {{task_description}}) - step-16-create-draft-pr ({{task_description}}, {{design_spec}}) - step-19d-verification-gate ({{philosophy_check}}, {{patterns_check}}) with direct env-var assignment: TASK_DESC={{task_description}} → TASK_DESC="$RECIPE_VAR_task_description" Security: bash does NOT re-execute $() or backtick substitutions when expanding a variable reference, so values containing $(evil) are safe. The env-var approach is the canonical injection-safe pattern for the 0.3.4+ runner (matching unquoted-heredoc usage elsewhere in this file). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Repo Guardian - PassedAll files in this PR have been reviewed and no ephemeral content was found.
No violations detected.
|
PR Triage ReportRisk: Medium | Priority: High | Type: Bugfix / Shell injection prevention SummaryReplaces quoted-heredoc captures with direct env-var assignment in 4 recipe steps (step-03, step-03b, step-16, step-19d) to fix heredoc terminator injection that caused Assessment
Key Finding: Overlapping PRsThree open PRs address the same quoting issue with different strategies:
Recommendation: If this approach is preferred, #4228 and #4236 should be closed as superseded before merging. The direct env-var approach is technically superior (immune to terminator injection by design), but the lack of regression tests is a gap given the blocking nature of the original issue. Action Required
|
- Replace fragile nested heredocs (<<EOFCOUNTS wrapping <<PY) with process substitution for parsing scope counts - Replace <<EOF commit message heredoc with printf to avoid delimiter collisions when $COMMIT_TITLE contains EOF-like strings - Add PRECOMMIT_DIR resolution with AMPLIHACK_HOME fallback so pre-commit scripts are found regardless of worktree layout - Add clarifying comments on EOFTASKDESC heredoc quoting rationale - Update test regex to accommodate quoted script paths Closes #4304, closes #4309, closes #4321, closes #4245, closes #4341 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace fragile nested heredocs (<<EOFCOUNTS wrapping <<PY) with process substitution for parsing scope counts - Replace <<EOF commit message heredoc with printf to avoid delimiter collisions when $COMMIT_TITLE contains EOF-like strings - Add PRECOMMIT_DIR resolution with AMPLIHACK_HOME fallback so pre-commit scripts are found regardless of worktree layout - Add clarifying comments on EOFTASKDESC heredoc quoting rationale - Update test regex to accommodate quoted script paths Closes #4304, closes #4309, closes #4321, closes #4245, closes #4341 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace fragile nested heredocs (<<EOFCOUNTS wrapping <<PY) with process substitution for parsing scope counts - Replace <<EOF commit message heredoc with printf to avoid delimiter collisions when $COMMIT_TITLE contains EOF-like strings - Add PRECOMMIT_DIR resolution with AMPLIHACK_HOME fallback so pre-commit scripts are found regardless of worktree layout - Add clarifying comments on EOFTASKDESC heredoc quoting rationale - Update test regex to accommodate quoted script paths Closes #4304, closes #4309, closes #4321, closes #4245, closes #4341 Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Problem
The recipe runner 0.3.4 does inline substitution inside quoted heredocs (
<<'EOF'). If a template variable value (e.g.final_requirementsfrom step-02c) contains the heredoc terminator string on its own line, the heredoc terminates early. When the remaining content after the early termination has an odd number of single quotes, bash raises:This is the exact failure in skwaq issue #469, which blocked every benchmark and PR workflow going through default-workflow/smart-orchestrator.
Root Cause Verified
The bug chain:
{{final_requirements}}directly into quoted heredoc bodyEOFREQSon its own line, heredoc terminates earlyFix
Replace quoted-heredoc captures with direct env-var assignment:
Security: bash does NOT re-execute$() or backtick substitutions when expanding a variable reference — so values containing $ (evil) are safe.
Scope
Fixed in 4 steps:
{{task_description}},{{final_requirements}}{{issue_creation}},{{task_description}}{{task_description}},{{design_spec}}{{philosophy_check}},{{patterns_check}}Validation
Tested with recipe-runner-rs 0.3.4: values containing heredoc terminators + single quotes now succeed with all content preserved.