fix: Potential fix for code scanning alert no. 11: Workflow does not contain permissions#190
Draft
fix: Potential fix for code scanning alert no. 11: Workflow does not contain permissions#190
Conversation
…in 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/openfoodfacts/facets-knowledge-panels/security/code-scanning/11
General fix:
Explicitly specify a minimal
permissions:block, either at the workflow level (applies to all jobs) or at the job level. According to best practices, you should grant only the permissions absolutely required by the steps in the workflow. Since this workflow mainly adds issues and PRs to GitHub Projects, which typically requires interacting with issues or PRs, but authentication is provided via a PAT, we can safely restrict the GITHUB_TOKEN to read-only permissions on repository contents.Detailed fix:
Add the following block at the very top level of the workflow, just after the
name:and beforeon::This restricts the GITHUB_TOKEN to read-only access to repository contents for the entire workflow, following least-privilege principles. If in the future a step requiring additional permissions is added, this can be revisited.
Which files/lines to change:
Edit
.github/workflows/github-projects.yml. Insert thepermissions:block (as above) after line 1, before line 3.Methods/imports/definitions needed:
No imports/definitions are needed for a workflow permissions block.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.