Skip to content

Commit 817ff79

Browse files
committed
Fix environment variable injection vulnerability in publish-test-results workflow
Fix code scanning alert for environment variable injection by correcting the tr command to properly sanitize PR_NUMBER. Changed from tr -cd '[0-9]' to tr -cd '0-9' to ensure only digits are allowed, preventing potential injection attacks from user-controlled workflow_run events.
1 parent b380004 commit 817ff79

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.github/workflows/publish-test-results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
eventjson=`cat 'artifacts/Event File/event.json'`
3939
prnumber=`echo $(jq -r '.pull_request.number' <<< "$eventjson")`
40-
echo "PR_NUMBER=$(echo $prnumber | tr -cd '[0-9]')" >> $GITHUB_ENV
40+
echo "PR_NUMBER=$(echo $prnumber | tr -cd '0-9')" >> $GITHUB_ENV
4141
4242
- name: Publish Unit Test Results
4343
uses: EnricoMi/publish-unit-test-result-action@v2

0 commit comments

Comments
 (0)