GeezerVison is showing github.com — Document what permissions are required · Issue #464 · github/codeql-action
Document what permissions are required #464DescriptionWe switched our repo to the default read-only permissions for GitHub Actions and our CodeQL workflow started to fail. Based on the failure message it seems the statuses: write permission is required.
P.S. Sorry to file an issue when the issue template selector only says to open an issue with GitHub Support, but none of the options really made sense since there's not "issues with a GitHub project" option. Reacted by Evan Lowry, Jarek Potiuk and Jamie Wilkinson Activityaeisenberg commented on Apr 28, 2021 Thanks, @brettcannon! Let me look at that.
We should also revisit our issue templates. aeisenberg commented on Apr 28, 2021 As far as I can tell, if you are using the default workflow, you should only need the following permissions:
permissions:
contents: read
security-events: write
pull-requests: read
Is your workflow doing anything special? The-Compiler commented on Apr 28, 2021 @aeisenberg I'm not entirely sure if you're aware (apologies if you are!), but there was a recent change which allows restricting the default GitHub secret to read-only access.
This seems like an excellent best practice to follow (principle of least privilege), but indeed the CodeQL action fails with a non-obvious error message:
[...]
request: {
method: 'PUT',
url: 'https://api.github.com/repos/qutebrowser/qutebrowser/code-scanning/analysis/status',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'CodeQL Action octokit-core.js/3.1.2 Node.js/12.13.1 (linux; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: [...]
request: { agent: [Agent], hook: [Function: bound bound register] }
},
documentation_url: 'https://docs.github.com/rest'
}
Error: Resource not accessible by integration
like @brettcannon I initially suspected it'd need statuses: write (based on the API URL used), but that didn't help.
Indeed just setting:
permissions:
security-events: write
seemed to fix this for me, but I probably wouldn't have found if it wasn't for this issue. Reacted by Max Milton, Jamie Wilkinson and RoseSecurity brettcannon commented on Apr 28, 2021 aeisenberg commented on Apr 28, 2021 Glad this worked out for you. We've recently (ie- yesterday) moved over to using permissions on our own repositories and workflows, so we are still figuring this out ourselves.
It sounds like the best solution here is to update the documentation. aeisenberg commented on Apr 28, 2021 It's possible that you will also need the: actions: read permission. Some code flows will make requests to introspect the current workflow and this permission is needed. So, if you get any more failures, try adding that permission as well.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|