Potential fix for code scanning alert no. 9: Workflow does not contain permissions#297
Merged
scottolsonjr merged 1 commit intomainfrom Mar 9, 2026
Merged
Potential fix for code scanning alert no. 9: Workflow does not contain permissions#297scottolsonjr merged 1 commit intomainfrom
scottolsonjr merged 1 commit intomainfrom
Conversation
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a root-level permissions block to the dotnet-check-build.yml GitHub Actions workflow, restricting the GITHUB_TOKEN to read-only access (contents: read). This addresses code scanning alert #9 about workflows missing explicit permissions declarations, following the principle of least privilege.
Changes:
- Added
permissions: contents: readat the workflow root level indotnet-check-build.ymlto explicitly restrict the token to read-only access.
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/rarelysimple/RarelySimple.AvatarScriptLink/security/code-scanning/9
In general, the fix is to explicitly declare a
permissionsblock either at the workflow root (applies to all jobs) or under the specific job(s), granting only the minimal permissions required for the job to run. For a typical build/test/package workflow that does not push commits, create releases, or modify issues/PRs, a safe default iscontents: read, which corresponds to a read-only GITHUB_TOKEN.For this particular workflow file
.github/workflows/dotnet-check-build.yml, the job simply reuses another workflow (./.github/workflows/dotnet-build.yml) to build, test, and package .NET code. There is no indication it needs to write to the repository or to issues/PRs. The best minimal, non-breaking fix is to add a root-levelpermissionsblock directly under the workflow name/run-name section, before theon:section, settingcontents: read. This will apply to all jobs in this workflow (currently justbuild) unless overridden, and will not change existing functional behavior other than restricting any unnecessary write permissions of the GITHUB_TOKEN.No new methods, imports, or external libraries are needed, because this is purely a YAML configuration change within the workflow file.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.