Skip to content

Conversation

@ashishkurmi
Copy link
Contributor

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:

  • nix-flake-update.yml

The following workflow file already has the least privileged token permission set:

  • nix.yml

Motivation and Context

Signed-off-by: Ashish Kurmi [email protected]

@ashishkurmi ashishkurmi changed the title ci: add minimum GitHub token permissions for workflows ci: add minimum GitHub token permissions for workflow Sep 8, 2022
@facebook-github-bot
Copy link
Contributor

@Atry has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Atry
Copy link
Contributor

Atry commented Sep 8, 2022

Hi @boahc077, could you trigger a CI run on your fork, checking if the GitHub Action is able to create a PR?

Comment on lines +4 to +6
permissions:
contents: read

Copy link
Contributor

@Atry Atry Sep 8, 2022

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?

Copy link
Contributor Author

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.

@ashishkurmi ashishkurmi requested a review from Atry September 9, 2022 02:51
Copy link
Contributor

@Atry Atry left a 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?

@ashishkurmi
Copy link
Contributor Author

@Atry It seems to be working fine: https://github.com/boahc077/hhvm/actions

@ashishkurmi ashishkurmi requested a review from Atry September 12, 2022 04:39
@Atry
Copy link
Contributor

Atry commented Sep 15, 2022

Thank you! @boahc077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants