GeezerVison is showing github.com — Updates the permissions block to be minimal by aeisenberg · Pull Request #689 · github/codeql-action
Conversation
aeisenberg
commented
Aug 9, 2021
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
And adds a permissions block to the README.
Fixes #464.
Merge / deployment checklist
- Confirm this change is backwards compatible with existing workflows.
- Confirm the readme has been updated if necessary.
- Confirm the changelog has been updated if necessary.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
From our last internal discussion about this, I believe that actions: read is (only) needed if you are analyzing a private repository, and security-events: write is (only) needed if you are not analyzing a pull request. And I think we need at least contents: read (or pull-requests: read for PRs). The overlapping scopes for PRs make this a bit confusing.
So perhaps let's go with the recommendation of actions: read, contents: read, security-events: write? If it turns out that's not entirely minimal, we can refine it again later.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Sure, and I can add some comments on when different scopes may not be needed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
aeisenberg
commented
Aug 9, 2021
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Here are the API calls we are making (just doing a code search for .request:
GET /repos/:owner/:repo/actions/runs/:run_id (actions: read)
GET /repos/:owner/:repo/actions/workflows (actions: read)
PUT /repos/:owner/:repo/code-scanning/analysis/status (security-events: write)
GET /enterprise/code-scanning/codeql-bundle/find/{tag} (security-events: read)
GET /enterprise/code-scanning/codeql-bundle/download/{asset_id} (security-events: read)
GET /repos/:owner/:repo/code-scanning/codeql/databases (security-events: read)
PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language (security-events: write)
PUT /repos/:owner/:repo/code-scanning/analysis (security-events: write)
Unless I've missed something, we only need security-events: write and actions: read. And the latter is only for private repos.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Plus you need enough permission to check out the repo itself in the workflow (but not in the Action), which I believe is either contents: read or pull_requests: read.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ah..yes. Again, only for private repos, it seems. So, contents: read guards the GET /repos/:owner/:repo/contents/:path endpoint. I don't see anything about pull requests, though. This would only be for things like editing the PR itself, or adding comments, etc.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
And adds a permissions block to the README.
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.
LGTM once you resolve the changelog conflict. Thanks!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Here are the API calls we are making (just doing a code search for .request:
GET /repos/:owner/:repo/actions/runs/:run_id (actions: read)
GET /repos/:owner/:repo/actions/workflows (actions: read)
PUT /repos/:owner/:repo/code-scanning/analysis/status (security-events: write)
GET /enterprise/code-scanning/codeql-bundle/find/{tag} (security-events: read)
GET /enterprise/code-scanning/codeql-bundle/download/{asset_id} (security-events: read)
GET /repos/:owner/:repo/code-scanning/codeql/databases (security-events: read)
PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language (security-events: write)
PUT /repos/:owner/:repo/code-scanning/analysis (security-events: write)
Unless I've missed something, we only need security-events: write and actions: read. And the latter is only for private repos.
@aeisenberg I am trying to figure out the required permissions for any GitHub Action. What is the process to get all the necessary permission? Thanks
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
There's no principled way of doing this that I can think of. An action can make any arbitrary request to the github api. And it can make requests in many ways (since they are just fundamentally REST requests): curl, gh, octokit, etc.
You could try setting very restrictive permissions, and slowly loosen them until you get your workflow passing. Alternatively, you can try to eyeball the code, which could be tricky if the action is doing non-standard things.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There's no principled way of doing this that I can think of. An action can make any arbitrary request to the github api. And it can make requests in many ways (since they are just fundamentally REST requests): curl, gh, octokit, etc.
You could try setting very restrictive permissions, and slowly loosen them until you get your workflow passing. Alternatively, you can try to eyeball the code, which could be tricky if the action is doing non-standard things.
Thank you!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Mar 18, 2026
This was referenced Aug 11, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|