-
Notifications
You must be signed in to change notification settings - Fork 3.1k
ci: add minimum GitHub token permissions for workflow #9177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Ashish Kurmi <[email protected]>
|
@Atry has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Hi @boahc077, could you trigger a CI run on your fork, checking if the GitHub Action is able to create a PR? |
| permissions: | ||
| contents: read | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this permission given that contents: write permission has been assigned to the only job of this workflow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the contents: read is not strictly needed here. Setting that at the workflow level helps if a new job is added to the workflow. In that case, the new job will have contents: read, which is a secure-by-default setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you trigger the CI from your fork, ensuring the GitHub Action is able to create a PR?
|
@Atry It seems to be working fine: https://github.com/boahc077/hhvm/actions |
|
Thank you! @boahc077 |
Description
This PR adds minimum token permissions for the GITHUB_TOKEN in GitHub Actions workflows using https://github.com/step-security/secure-workflows.
The GitHub Actions workflow has a GITHUB_TOKEN with write access to multiple scopes.
Here is an example of the permissions in one of the workflow runs:
https://github.com/facebook/hhvm/runs/8220542290?check_suite_focus=true#step:1:19
After this change, the scopes will be reduced to the minimum needed for the following workflow:
The following workflow file already has the least privileged token permission set:
Motivation and Context
https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
Signed-off-by: Ashish Kurmi [email protected]