Skip to content

Commit f7327dd

Browse files
authored
fix: avoid using comment body directly (#8851)
1 parent 4b81cfa commit f7327dd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/pr-deploy.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,19 @@ jobs:
234234
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
235235
experiments=${{ github.event.inputs.experiments }}
236236
else
237-
experiments=$(echo "${{ github.event.comment.body }}" | grep -oP '(?<=--experiments )[^ ]+')
237+
# extract experiments part
238+
extracted_experiments=$(echo "$COMMENT_BODY" | grep -oP '(?<=--experiments )[^ ]+')
239+
# Validate that the experiments is a comma-separated list of alphanumeric strings, "*", or "-"
240+
if [[ $extracted_experiments =~ ^[a-zA-Z0-9_*,\"-]+$ ]]; then
241+
experiments=$extracted_experiments
242+
else
243+
echo "Invalid input: $extracted_experiments"
244+
exit 1
245+
fi
238246
fi
239247
echo "experiments=$experiments" >> $GITHUB_OUTPUT
248+
env:
249+
COMMENT_BODY: ${{ github.event.comment.body || '' }}
240250

241251
- name: Create values.yaml
242252
run: |

0 commit comments

Comments
 (0)