File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,13 +56,16 @@ jobs:
5656 - name : Convert Jacoco integ test report to Cobertura
5757 run : python3 .github/scripts/cover2cover.py target/jacoco-report/jacoco-it/jacoco.xml src/main/java > target/jacoco-report/cobertura-it.xml
5858 - name : Save PR number
59- env :
60- PR_NUMBER : ${{ github.event.number }}
61- PR_SHA : ${{ github.event.pull_request.head.sha }}
6259 run : |
6360 mkdir -p ./pr/jacoco-report
64- echo "$PR_NUMBER" | tr -cd '0-9' > ./pr/NR
65- echo "$PR_SHA" | tr -cd 'a-fA-F0-9' > ./pr/SHA
61+
62+ # Safely extract and sanitize PR number using GITHUB_EVENT_PATH
63+ PR_NUMBER=$(jq -r '.number // empty' "$GITHUB_EVENT_PATH" | tr -cd '0-9')
64+ echo "$PR_NUMBER" > ./pr/NR
65+
66+ # Safely extract and sanitize PR SHA using GITHUB_EVENT_PATH
67+ PR_SHA=$(jq -r '.pull_request.head.sha // empty' "$GITHUB_EVENT_PATH" | tr -cd 'a-fA-F0-9')
68+ echo "$PR_SHA" > ./pr/SHA
6669
6770 cp target/jacoco-report/cobertura.xml ./pr/jacoco-report/cobertura.xml
6871 cp target/jacoco-report/cobertura-it.xml ./pr/jacoco-report/cobertura-it.xml
You can’t perform that action at this time.
0 commit comments