-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
ci: Add minimum GitHub token permissions for workflows #22786
Conversation
@varunsh-coder thank you for submitting the PR! Could you squash these two commits and removed the commit message in the second one? |
Signed-off-by: Varun Sharma <varunsh@stepsecurity.io>
5a5dde1
to
20178a2
Compare
Done! |
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for the explanation and pull request @varunsh-coder! This is clearly an improvement, but I'm curious whether it'd be better to just set the default token permissions to "restrictive" for the repository, as documented here, rather than doing overrides to reduce permissions in individual workflows: It seems like that would protect us better if future workflows are added. (I think we'd still need the "security events" hunk as that's an increase in permissions?) |
Is there a way to run this scorecard without installing their GitHub Action? |
Hi @timabbott, you can also set the default token permissions to "restrictive" for the repository, and yes that will help with future workflows as well. Setting in the workflow file has couple of advantages:
Yes, the Please let me know whatever you decide and if you want me to update the PR. Thanks! |
Yes, you can run it using the CLI. https://github.com/ossf/scorecard#installation For some repositories (what publish a package), the scores are also available at https://deps.dev |
Merged, thanks for the contribution and information @varunsh-coder! |
Also posted https://chat.zulip.org/#narrow/stream/43-automated-testing/topic/GitHub.20token.20permissions/near/1427444; we'll want to do something similar for our other major repositories like zulip/zulip-mobile. |
This limits the ability for an Action to do mischief with this token. Fixes #22786. Signed-off-by: Varun Sharma <varunsh@stepsecurity.io>
Description
This PR adds minimum token permissions for the GITHUB_TOKEN in GitHub Actions workflows using https://github.com/step-security/secure-workflows.
All GitHub Actions workflows have a GITHUB_TOKEN with
write
access to multiple scopes.Here is an example of the permissions in one of the workflows:
https://github.com/zulip/zulip/runs/8006109927?check_suite_focus=true#step:1:19
After this change, the scopes will be reduced to the minimum needed for the workflows.
Motivation
https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
Signed-off-by: Varun Sharma varunsh@stepsecurity.io
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: