Potential fix for code scanning alert no. 7: Workflow does not contain permissions #266
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/yourtablecloth/TableCloth/security/code-scanning/7
In general, this issue is fixed by explicitly defining a
permissions:block that limits theGITHUB_TOKENto the minimum scopes required by the workflow. This can be set at the top level (applies to all jobs) or per job (overrides the top-level setting). For this workflow, the jobs only need to read the repository contents to perform checkout and build; they do not create releases, comment on issues/PRs, or push changes, socontents: readis sufficient.The single best fix without changing existing functionality is to add a top‑level
permissions:block right after thename:(or before/afteron:) that setscontents: read. This will apply to bothvalidate-versionandbuildjobs, and is compatible withactions/checkout,actions/setup-dotnet, andactions/upload-artifact, which do not require write permissions to repository contents. No other code changes, methods, or imports are needed: we only adjust the YAML configuration.Concretely, in
.github/workflows/build.yml, insert:near the top of the file (e.g., between line 1 and line 3 in the snippet provided). No additional permissions appear necessary given the current steps.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.