Skip to content

Commit 6e2cb94

Browse files
committed
Fix codeql error in new workflow
1 parent 54a8256 commit 6e2cb94

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎.github/workflows/dependabot-refresh-lockfiles.yml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,25 @@ jobs:
6868
pnpm install --lockfile-only
6969
7070
- name: Commit lockfile updates
71+
env:
72+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
7173
run: |
74+
set -euo pipefail
75+
7276
git config user.name "github-actions[bot]"
7377
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
7478
79+
# Reject unexpected ref values before using them in git commands.
80+
if [[ ! "$PR_HEAD_REF" =~ ^[A-Za-z0-9._/-]+$ ]] || [[ "$PR_HEAD_REF" == -* ]] || [[ "$PR_HEAD_REF" == *..* ]]; then
81+
echo "Invalid pull request head ref: $PR_HEAD_REF"
82+
exit 1
83+
fi
84+
7585
if git diff --quiet -- uv.lock 3rdparty/python/default.lock pnpm-lock.yaml; then
7686
echo "No lockfile updates needed"
7787
exit 0
7888
fi
7989
8090
git add uv.lock 3rdparty/python/default.lock pnpm-lock.yaml
8191
git commit -m "chore: refresh lockfiles for dependabot"
82-
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
92+
git push origin "HEAD:$PR_HEAD_REF"

0 commit comments

Comments
 (0)