Potential fix for code scanning alert no. 5: Workflow does not contain permissions#128
Merged
Potential fix for code scanning alert no. 5: Workflow does not contain permissions#128
Conversation
…n 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/green-code-initiative/creedengo-python/security/code-scanning/5
In general, the fix is to add an explicit
permissionssection specifying the minimal scopes required for the workflow. You can add this either at the root (applies to all jobs) or per job. Here, only thebuildanduploadjobs useGITHUB_TOKENfor release operations, which requirecontents: write; thechecksjob only inspects permissions and does not need write access. The cleanest least‑privilege fix is: set restrictive default permissions at the workflow root (e.g.,contents: read) and then override them withcontents: writeonly for the jobs that create and upload release assets.Concretely:
.github/workflows/tag_release.yml, add apermissions:block aftername: Tag Release(or afteron:) settingcontents: read.buildjob, add apermissions:block withcontents: writebecauseactions/create-release@v1needs to create a release (which writes to repository contents/releases).uploadjob, add apermissions:block withcontents: writebecauseactions/upload-release-asset@v1needs to upload assets to an existing release.checksjob with default (inherited)contents: read, which is sufficient since it doesn’t useGITHUB_TOKENexplicitly.No new imports, methods, or external dependencies are required; this is purely a workflow-permissions configuration change in
.github/workflows/tag_release.yml.Suggested fixes powered by Copilot Autofix. Review carefully before merging.