|
1 | 1 | name: Content Checks |
2 | 2 | on: |
| 3 | + # Use `pull_request_target` to run the workflow on the PR base branch (e.g. `origin/main`) |
| 4 | + # Avoid using `pull_request` because it runs the workflow on the PR head branch (e.g. `origin/pr-branch`) |
| 5 | + # Don't run any code from the PR head branch because it's untrusted and could be malicious. |
| 6 | + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target |
| 7 | + # See: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ |
3 | 8 | pull_request_target: |
4 | 9 | types: |
5 | 10 | - opened |
|
28 | 33 | with: |
29 | 34 | fetch-depth: 2 |
30 | 35 |
|
| 36 | + # Avoid checking out any code outside of content/ |
31 | 37 | - name: Sparse checkout of content directory from fork to temp directory |
32 | 38 | if: ${{ github.event_name == 'pull_request_target' }} |
33 | 39 | uses: actions/checkout@v3 |
@@ -61,14 +67,18 @@ jobs: |
61 | 67 | echo "Event name: ${{ github.event_name }}" |
62 | 68 | echo "Pull request number: ${{ github.event.pull_request.number }}" |
63 | 69 | echo "Pull request user login: ${{ github.event.pull_request.user.login }}" |
64 | | - echo "Base ref: ${{ github.event.pull_request.base.ref }}" |
65 | | - echo "Head sha: ${{ github.event.pull_request.head.sha }}" |
| 70 | + echo "Base (target) ref: ${{ github.event.pull_request.base.ref }}" |
| 71 | + echo "Base (target) sha: ${{ github.event.pull_request.base.sha }}" |
| 72 | + echo "Head (source) ref: ${{ github.event.pull_request.head.ref }}" |
| 73 | + echo "Head (source) sha: ${{ github.event.pull_request.head.sha }}" |
66 | 74 | git status |
67 | 75 | git remote -v |
68 | 76 | git log --oneline -n 10 |
69 | 77 |
|
70 | 78 | - name: Run quality checks |
71 | | - # Don't run local code for security reasons |
| 79 | + # The local code is untrusted and could be malicious. Don't run it. |
| 80 | + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target |
| 81 | + # See: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ |
72 | 82 | uses: Roblox/creator-docs/.github/actions/quality-checks@main |
73 | 83 | with: |
74 | 84 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments