Commit e592877
authored
[tooling] Fix contribution message workflow permission issue on PR from fork (#224)
Problem:
* `pull_request` trigger type is forced for PRs that **come from forks**
to only have `read` permission for all scopes regardless of what we set
explicitly in the workflow -> results in permission issue in
contribution comment
Source:
https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflows-in-forked-repositories
Proposed solution:
* Use `pull_request_target` with restricted scope for GITHUB_TOKEN
* Checkout to base repository default branch instead of the HEAD of the
forked repository for security reasons (ensures we only run safe and
trusted code in the main branch)
Source:
https://www.linkedin.com/pulse/how-access-secrets-running-tests-forked-pull-requests-kylee-fields-7vcne/
Note: this change will only take effect for PRs that appear AFTER this
PR is merged.
Alternative solution:
* more complicated flow where we have a `pull_request` trigger that
builds relevant artifacts (if needed), then use `workflow_runs` trigger
to comment to github (see more here:
https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/)1 parent 8c007cd commit e592877
1 file changed
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments