[security] Set minimum permissions for workflows #806
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#806
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Setting minimum permissions to your workflows is important to keep your repository safe against supply-chain attacks. By default, GitHub gives higher permissions then necessary to the GITHUB_TOKEN generated for workflows. I see
ci.ymldoes not need many permissions to run the tests. The actions used byci.yml,msys2/setup-msys2andactions/checkout, only need access to read the repository code. Thus, we can reduce the permissions tocontents: readand should be good to go. This change should not impact any tests for any environments :) If you agree with the changes, I can open a PR!This is considered good-practice and recommended by GitHub itself and by other security tools, such as Scorecards and StepSecurity.
Additional Context
I'm Gabriela and I work on behalf of Google and the OpenSSF suggesting supply-chain security changes :)
Hi @gabibguti,
Thank you for letting us know. I suppose that you're suggesting the following actions to us.
Set "Read repository contents and packages permissions" to the "Workflow permission" in the Settings tab of the repo.
Reference: Setting the permissions of the GITHUB_TOKEN for your repository - GitHub Docs
As you described, add the following lines to
ci.yml. Similar (same?) to above settings, but since this form is written in code, it may propagate to other forks.Reference: Configuring the default GITHUB_TOKEN permissions
I think we need to do both of them. Because 1. helps all branches which don't have
permissions:inci.yml.But 2. for
devbranch is also good because it's explicit and may help future improvements or suggestions from other contributors.Please let us know if there are mistakes or misunderstands.
Thanks for information !
As suggested by @t-mat in (1),
I updated "Workflow permissions" to "Read repository content" only.
I think none of our CI tests require more than that, so it should be okay.
A (2) follow up is also possible.
@t-mat Yes! Perfect. It's exactly as you explained.
@t-mat @Cyan4973 Let me know if you'd like me to open a PR for (2) :)
Permissions restricted to
content: readin #807 . Thanks for the advise !