-
Notifications
You must be signed in to change notification settings - Fork 183
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
Workflow Permissions Should Be Least-Privileged #415
Comments
I did not know that was possible. This is very useful feedback. With I might take a little time to implement this. If you feel adventurous, maybe you might consider sending me a pull request... |
I completely spaced and forgot to include useful links to the documentation:
If I can get my head wrapped around everything that is required, I'll see about taking a crack at a PR. It probably makes sense for me to explore my own repo, get it working, and dial it back to the bare minimum. There will probably be a little trial by fire to see what breaks if a specific permission is not enabled. Honestly, it doesn't look like a whole a lot is necessary. |
Thanks for the pointers, if you don't get around to it, at least I know where to start now. |
I've reduced my workflows down to: jobs:
i-d-job:
permissions:
contents: write Everything is still working. I didn't see anything that used the GitHub CLI or Pull Requests. There's a couple places that use the GitHub API directly, but they all seem to be read-only (which should work without any change). There seems to be only 4 touch points so the changes and PR part are pretty trivial. I'm not sure how you test this though. I can't say that I've used a GitHub repository as a template. Is there a way to check things end-to-end before approving the forthcoming PR? |
The template instructions indicate that when setting up a new repository:
This is unnecessarily permissive and applies to all repositories under the account or organization. The required permissions can easily be added to the workflow configuration. This approach would have the added benefit of not requiring the author to change their settings.
The following permissions can be added to a
job
:contents: write
is the bare minimum to add and push content, including new branches. If PRs will be created, thenpull-requests: write
should be added; otherwise, it may not be needed. It looked like the archive workflow might be working with PRs, but perhaps it only needs read access. Theghpages.yml
workflow might also need or wantpages: write
.I have successfully applied these changes to my workflows without issue, while my account settings only allow read permissions on the token by default. If this change were applied, it should reduce the manual operations down to a single step.
The text was updated successfully, but these errors were encountered: