Skip to content

Commit e0ad9e4

Browse files
fix: allow rerun on forked PRs (#41)
* fix: allow rerun on forked PRs * Update check-user-permission action version to sha --------- Co-authored-by: Chris Ferry <chrisferry@gmail.com>
1 parent 2409f58 commit e0ad9e4

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/checkmarx.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ permissions:
88
security-events: write # to upload the scan results
99

1010
on:
11-
pull_request:
12-
branches: [ '**' ]
11+
pull_request_target:
12+
types: [opened, synchronize, reopened]
1313
push:
1414
branches: [ 'main' ]
1515
concurrency:
@@ -26,8 +26,30 @@ jobs:
2626
runs-on: ubuntu-latest
2727

2828
steps:
29+
# From https://michaelheap.com/access-secrets-from-forks/
30+
# Also see https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
31+
- name: Get User Permission
32+
id: checkAccess
33+
uses: actions-cool/check-user-permission@7b90a27f92f3961b368376107661682c441f6103 #v2
34+
with:
35+
require: write
36+
username: ${{ github.triggering_actor }}
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Check User Permission
40+
if: steps.checkAccess.outputs.require-result == 'false'
41+
run: |
42+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
43+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
44+
echo "Job originally triggered by ${{ github.actor }}"
45+
exit 1
46+
47+
# This is dangerous without the first access check
2948
- name: Checkout
3049
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
50+
with:
51+
# Yes we do need to specify head explicitly here (read github article)
52+
ref: ${{ github.event.pull_request.head.sha }}
3153

3254
- name: Install dependencies
3355
run: |

0 commit comments

Comments
 (0)