-
-
Notifications
You must be signed in to change notification settings - Fork 813
Add missing GitHub action explicit permissions #5855
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
base: main
Are you sure you want to change the base?
Conversation
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.
Took me a while to find the issues you were referring to, they're locked behind a login and permissions.
Good idea to reduce where possible, but hard to test properly before merging. I can think of two potential issues after reviewing the changes, but am not 100% sure.
permissions: | ||
actions: write | ||
contents: write |
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.
permissions: | |
actions: write | |
contents: write | |
permissions: | |
actions: write | |
contents: write | |
pull_requests: write |
It'll also need permissions to create a pull request
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.
I'm not sure we need this one. The pull_requedt permission from the documentation is for modifying an existing pull request like adding a label https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-pull-requests
I think I'll have to test ...
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.
On that page it says that POST /repos/{owner}/{repo}/pulls
is part of pull_requests
, suggesting to me that we do need it. But I'm also willing to test without, not a major issue if this workflow fails once because of missing permissions.
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: |
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.
Doesn't it need permission to create inline comments/issues for lint issues that were found?
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.
Well I tried to test and I didn't manage to get any annotations to be displayed... I tried for yaml I should probably try for ktlint.
With the current permission the annotations are in the checks.
There is something I don't fully understand on the checks yet. I also looked in the documentation of the permissions and I didn't find things related to annotations.
Summary
Fix missing permission properties reported by CodeQL on its first run. The permission needs to be explicit and not to widely open at the workflow level so that we can control during review process what we are exposing. It is also helpful to limit what can a third party action can do in our CI env.
Checklist