Potential fix for code scanning alert no. 5: Workflow does not contain permissions #55
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/edgee-cloud/ga-component/security/code-scanning/5
To fix this, explicitly declare
permissionsso that theGITHUB_TOKENused in the workflow has only the minimal scopes required. Because multiple jobs here only need to read the repository contents, we can define a root-levelpermissions: contents: readthat applies to all jobs, and then override it in specific jobs that need additional rights. Theclippyjob already correctly narrows itself tochecks: write, so we should keep that. Thecoveragejob, which reports to Coveralls, typically needs to create or update checks, so we should give itchecks: writein addition tocontents: read.Concretely:
.github/workflows/check.yml, add a workflow-levelpermissions:block right after theon:section (beforeenv:), settingcontents: read.clippy’s existingpermissions: checks: writeas-is (job-level permissions override the workflow default).permissions:block to thecoveragejob specifying bothcontents: readandchecks: write, inserted directly underruns-on: ubuntu-latest.No additional imports or external libraries are needed; this is purely a YAML configuration change.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.