fix(core): handle heredoc in command substitution guard - #1701
Conversation
|
@liqiongyu Thank you for this valuable PR! The heredoc support is a great addition to the shell command parser. We've reviewed the changes and identified a couple of issues that need to be addressed before we can merge: Issue 1: Security vulnerability - Heredoc syntax in comments suppresses substitution detection [P1]Problem: Attack Example: # Fake heredoc <<'EOF' (this is just a comment)
$(rm -rf /) # This executes but isn't flagged!
EOFIssue 2: False positives for command substitution inside comments [P2 - Enhancement]Problem: Example: # Note: $(rm -rf /) is dangerous
echo helloThis should be allowed, but currently may trigger detection. Suggested FixBoth issues can be addressed by adding
|
|
@tanzhenxin I addressed both items you pointed out:
CI is green on all platforms now. Could you please take another look when you have time? Thanks! |
…d-substitution fix(core): handle heredoc in command substitution guard
Fixes #1698
What
detectCommandSubstitution()to understand heredocs.<<'EOF').$()/ backticks in heredoc bodies when the delimiter is unquoted (because bash would execute them).Why
Users saving sessions/logs to Markdown often include ``` and
$()/backticks as plain text. The previous detector could false-positive on these, blocking safe file writes.Test