.github/workflows/build.yml: Potential fix for code scanning alert no. 7: Workflow does not contain permissions #851
+3
−0
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/scylladb/scylla-machine-image/security/code-scanning/7
In general, the fix is to add an explicit
permissionsblock either at the workflow root (applies to all jobs) or within the specific job that needs it. For this workflow, the job only needs to read repository contents (for checkout) and run commands in Docker containers; there’s no indication that it needs to write to the repo, PRs, issues, etc. Therefore, we can safely restrictGITHUB_TOKENtocontents: read.The best minimal fix without changing functionality is to add a top-level
permissionssection right after theon:block. This will apply to thebuildjob (and any future jobs that don’t override permissions) and setcontents: readas recommended by CodeQL. No other changes to steps, commands, or actions are required. The edit will be in.github/workflows/build.yml, inserting:at the root level, aligned with
on:andjobs:. No imports or external libraries are involved.Suggested fixes powered by Copilot Autofix. Review carefully before merging.