Skip to content

Commit 1cc71e4

Browse files
committed
Fix CodeQL code injection warning
Use env var instead of direct expression interpolation for head.ref in run blocks to prevent potential code injection via attacker-controlled branch names.
1 parent f5d091f commit 1cc71e4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

.github/workflows/lint.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ jobs:
4040
4141
- name: Commit and push changes
4242
if: env.changes == 'true' && github.event.pull_request.head.repo.full_name == github.repository
43+
env:
44+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
4345
run: |
44-
git checkout -b ${{ github.event.pull_request.head.ref }}
46+
git checkout -b "$HEAD_REF"
4547
git add .
4648
git commit -m "chore: auto-corrected with RuboCop"
47-
git push origin ${{ github.event.pull_request.head.ref }}
49+
git push origin "$HEAD_REF"

0 commit comments

Comments
 (0)