-
-
Notifications
You must be signed in to change notification settings - Fork 392
chore: define permissions in workflows and pin actions to SHA #2211
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
Open
Florence-Njeri
wants to merge
3
commits into
asyncapi:master
Choose a base branch
from
Florence-Njeri:add-perms-to-workflows
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: asyncapi/generator
Length of output: 50374
🌐 Web query:
GitHub Actions workflow permissions GITHUB_TOKEN permissions do not affect personal access token secrets GH_TOKEN gh CLI GITHUB_TOKEN environment variable official documentation💡 Result:
The GitHub Actions workflow permissions block (using the permissions key) strictly governs the permissions granted to the default GITHUB_TOKEN secret [1][2]. These settings do not affect or limit other credentials, such as personal access tokens (PATs) or other GitHub App installation access tokens that you manually provide as secrets [1][3]. When you use the GitHub CLI (gh) in a workflow, you must explicitly provide an authentication token via an environment variable, typically GH_TOKEN [4][5]. While both GITHUB_TOKEN and GH_TOKEN are accepted by the CLI, using GH_TOKEN is the recommended best practice [6][5]. The permissions of the gh CLI operations will be determined entirely by the token provided in the GH_TOKEN variable, regardless of the workflow-level permissions set for the GITHUB_TOKEN [1][6]. If your workflow requires permissions exceeding what is granted to the default GITHUB_TOKEN, you must use a separate credential (like a PAT or a different GitHub App token) stored as a secret [1][3]. You should then pass this secret as the GH_TOKEN environment variable for your gh CLI commands [3][7]. Note that when using custom tokens, you are responsible for managing their scope and permissions, as they are not subject to the restricted GITHUB_TOKEN permission settings defined in the workflow YAML [1][2]. Additionally, be aware that standard tools like actions/checkout may automatically configure git authentication using the GITHUB_TOKEN by default [8]. If you intend to use a different token for git operations, you may need to configure the action (e.g., setting persist-credentials: false) to prevent the default token from taking precedence [8].
Citations:
gh auth setup-gitdoes not override the git user following anactions/checkoutinvocation cli/cli#10905Reduce the workflow token permissions.
The website checkout,
git push, andgh pr createusesecrets.GH_TOKEN, not the workflow token. Set the job permissions tocontents: readand removecontents: writeandpull-requests: write.🤖 Prompt for AI Agents