Potential fix for code scanning alert no. 9: Workflow does not contain permissions#2960
Closed
kaitlynnefuery wants to merge 1 commit intomainfrom
Closed
Potential fix for code scanning alert no. 9: Workflow does not contain permissions#2960kaitlynnefuery wants to merge 1 commit intomainfrom
kaitlynnefuery wants to merge 1 commit intomainfrom
Conversation
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖 This PR introduced no changes to the javascript bundle 🙌 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Potential fix for https://github.com/hashicorp/dev-portal/security/code-scanning/9
In general, to fix this category of issue you add a
permissionsblock either at the workflow root or within each job to explicitly scope what the automatically providedGITHUB_TOKENcan do. For a workflow that only checks out code and runs local tooling without calling GitHub APIs to modify resources,contents: readis typically sufficient and aligns with GitHub’s recommended minimal baseline.For this specific workflow (
.github/workflows/register-preview-url.yml), theon-deployjob checks out the repository and runs Node-based tooling. None of the shown steps require write access to repository contents, issues, PRs, or other GitHub resources viaGITHUB_TOKEN. The least-privilege fix is therefore to add apermissionsblock underjobs.on-deployspecifyingcontents: read. This directly addresses CodeQL’s warning and keeps existing behavior unchanged, since read access is already required to performactions/checkout. Concretely, insert:between
runs-on: ubuntu-latestandif: ...in theon-deployjob. No imports or additional definitions are needed, as this is purely a YAML configuration change.Suggested fixes powered by Copilot Autofix. Review carefully before merging.