Potential fix for code scanning alert no. 194: Workflow does not contain permissions#270
Draft
mgtennant wants to merge 1 commit into
Draft
Potential fix for code scanning alert no. 194: Workflow does not contain permissions#270mgtennant wants to merge 1 commit into
mgtennant wants to merge 1 commit into
Conversation
…ain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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/bcgov/nr-ticdi/security/code-scanning/194
To fix the problem, explicitly define
permissionsfor the workflow or for the affected jobs so theGITHUB_TOKENdoes not implicitly inherit broad repository defaults. The safest general approach is to add a restrictivepermissionsblock at the workflow root (applies to all jobs) and then override/expand only where needed.In this file, the only job that currently declares permissions is
promote(packages: write). Thevars,deploy-test, anddeploy-prodjobs do not appear to need write access to repository contents or other scopes; they mostly call actions and a reusable workflow and use secrets. The single best minimal change is to add a root-levelpermissionsblock near the top of the file (aftername:and beforeon:) that sets all scopes to read-only by default. Jobs that require broader permissions (likepromote) will continue to override this with their ownpermissionsblock, which already exists. No imports or additional methods are needed; this is a pure YAML configuration change in.github/workflows/merge.yml.Suggested fixes powered by Copilot Autofix. Review carefully before merging.