Skip to content

Commit af19943

Browse files
mesh-2092: secure from parameter injection
1 parent ecaab6c commit af19943

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/dependabot-auto-merge.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
uses: actions/checkout@v4
2323
with:
2424
fetch-depth: 0
25-
ref: ${{ startsWith(github.event.pull_request.head.ref, 'dependabot/') && github.event.pull_request.head.ref || github.ref }}
2625
repository: ${{ github.event.pull_request.head.repo.full_name }}
2726

2827
- name: Install Python 3.11
@@ -43,13 +42,21 @@ jobs:
4342
run: make lint
4443

4544
- name: Commit and push changes
45+
env:
46+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
4647
run: |
4748
git config user.name "github-actions[bot]"
4849
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
if [ -z "$PR_HEAD_REF" ] || ! echo "$PR_HEAD_REF" | grep -Eq '^dependabot/'; then
52+
echo "PR head ref '$PR_HEAD_REF' is not a allowed Dependabot branch; skipping push."
53+
exit 1
54+
fi
55+
4956
if git status --porcelain | grep .; then
5057
git add -A
5158
git commit -m "mesh-2092: apply make update changes"
52-
git push
59+
git push origin HEAD:"$PR_HEAD_REF"
5360
else
5461
echo "No changes to commit"
5562
fi

0 commit comments

Comments
 (0)