mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 08:01:26 +00:00
fix(ci): use random delimiters for untrusted multiline workflow values (#10706)
* fix(ci): use a random delimiter for the review prompt env var * fix(ci): use a random delimiter for the review command extra_prompt output
This commit is contained in:
@@ -167,8 +167,14 @@ jobs:
|
||||
env:
|
||||
EXTRA_PROMPT: ${{ inputs.extra_prompt }}
|
||||
run: |
|
||||
# prior-comments.md is PR comment text verbatim, and commenting needs no write access.
|
||||
# With a fixed delimiter, a comment containing a bare `EOF` line closes the block early:
|
||||
# the step dies, and whatever follows in that comment is read as further environment
|
||||
# assignments for the rest of this job, which holds the review tokens. Hence a random
|
||||
# delimiter, per GitHub's guidance for untrusted multiline values.
|
||||
delimiter="REVIEW_PROMPT_EOF_$(openssl rand -hex 16)"
|
||||
{
|
||||
echo 'REVIEW_PROMPT<<EOF'
|
||||
echo "REVIEW_PROMPT<<$delimiter"
|
||||
cat REVIEW.md
|
||||
echo ''
|
||||
cat .claude/review-prompt.md
|
||||
@@ -182,7 +188,7 @@ jobs:
|
||||
echo ''
|
||||
cat prior-comments.md
|
||||
fi
|
||||
echo 'EOF'
|
||||
echo "$delimiter"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Automatic PR Review
|
||||
|
||||
@@ -25,16 +25,20 @@ jobs:
|
||||
REMAINDER_FIRST_LINE=${FIRST_LINE#"$FIRST_WORD"}
|
||||
REMAINDER_FIRST_LINE=${REMAINDER_FIRST_LINE# }
|
||||
REST=$(printf '%s' "$BODY" | tail -n +2)
|
||||
# The value is the comment body, which anyone can write. A fixed delimiter lets a
|
||||
# comment close the block early and have the rest of itself read as further step
|
||||
# outputs, so the delimiter has to be unguessable.
|
||||
delimiter="EXTRA_EOF_$(openssl rand -hex 16)"
|
||||
{
|
||||
echo "command=$COMMAND"
|
||||
echo 'extra_prompt<<EXTRA_EOF'
|
||||
echo "extra_prompt<<$delimiter"
|
||||
if [ -n "$REMAINDER_FIRST_LINE" ]; then
|
||||
printf '%s\n' "$REMAINDER_FIRST_LINE"
|
||||
fi
|
||||
if [ -n "$REST" ]; then
|
||||
printf '%s\n' "$REST"
|
||||
fi
|
||||
echo 'EXTRA_EOF'
|
||||
echo "$delimiter"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
;;
|
||||
*)
|
||||
|
||||
Reference in New Issue
Block a user