Skip to content

Commit

Permalink
ci(pr-title): Escape variables used in bash scripts (#992)
Browse files Browse the repository at this point in the history
Don't insert github expressions directly in the bash script.
- It breaks if there are [backticks] or [quotes] inside the variable.
- It's a security issue, it allows arbitrary code injections from the PR
description.

The solution is to put them into env variables first.
  • Loading branch information
aborgna-q authored May 2, 2024
1 parent 8651839 commit 4b9d3da
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ jobs:
- name: Check for breaking change flag
id: breaking
run: |
if [[ "${{ github.event.pull_request.title }}" =~ ^.*\!:.*$ ]]; then
if [[ "${PR_TITLE}" =~ ^.*\!:.*$ ]]; then
echo "breaking=true" >> $GITHUB_OUTPUT
else
echo "breaking=false" >> $GITHUB_OUTPUT
fi
# Check if the PR comment has a "BREAKING CHANGE:" footer describing
# the breaking change.
if [[ "${{ github.event.pull_request.body }}" != *"BREAKING CHANGE:"* ]]; then
if [[ "${PR_BODY}" != *"BREAKING CHANGE:"* ]]; then
echo "has_breaking_footer=false" >> $GITHUB_OUTPUT
else
echo "has_breaking_footer=true" >> $GITHUB_OUTPUT
fi
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}

# Post a help comment if the PR title indicates a breaking change but does
# not contain a "BREAKING CHANGE:" footer.
Expand Down

0 comments on commit 4b9d3da

Please sign in to comment.