@@ -8,14 +8,6 @@ permissions:
88 security-events : write # to upload the scan results
99
1010on :
11- # pull_request_target allows secrets to be read from fork PRs.
12- # DO NOT build or run checked out code from this job.
13- #
14- # Please note: Due to how this job is run, any changes to this
15- # job will only take affect when merged to main.
16- #
17- # From https://michaelheap.com/access-secrets-from-forks/
18- # Also see https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
1911 pull_request_target :
2012 types : [opened, synchronize, reopened]
2113 push :
@@ -34,10 +26,22 @@ jobs:
3426 runs-on : ubuntu-latest
3527
3628 steps :
37- - name : Check access
38- if : ${{ github.event.pull_request.author_association != 'COLLABORATOR' && github.event.pull_request.author_association != 'OWNER' }}
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'
3941 run : |
40- echo "This job needs re-running by someone with collaboration permissions."
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 }}"
4145 exit 1
4246
4347 # This is dangerous without the first access check
0 commit comments