Potential fixes for 2 code scanning alerts #60
Merged
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.
As part of the organization's transition to default read-only permissions for the GITHUB_TOKEN, this pull request addresses a missing permission in the workflow that triggered a code scanning alert.
This PR explicitly adds the required read permissions to align with the default read only permission and is part of a larger effort for this OKR https://github.com/github/security-services/issues/455
Potential fixes for 2 code scanning alerts from the Copilot AutoFix: Missing Permissions in Workflows security campaign:
https://github.com/github/check-all/security/code-scanning/4
The best way to fix the problem is to explicitly set the minimal required permissions for the workflow (or job), limiting the GITHUB_TOKEN privileges according to the principle of least privilege. In this workflow, the job is publishing to npm and interacting with release info, but no actions here modify repository contents or interact with pull requests. The safest and least privilege starting point is
contents: read, which is sufficient for checking out code and reading repository files but does not grant write access to contents. To implement the fix, add apermissions:block to either the root level (abovejobs:) or specifically to thepublish-npmjob (belowruns-on:). The standard approach is to add it at the root level so it applies globally (unless jobs require something different).Changes needed:
on:clause (as per GitHub Actions docs).No additional imports or definitions are needed.
https://github.com/github/check-all/security/code-scanning/3
To address the issue, explicitly set the appropriate
permissionsat the job or workflow level. In this workflow, since the steps only checkout code and perform build/test actions (no issue, pull request, or release modifications), it is sufficient to grant read access to repository contents. The minimal best practice change is to addpermissions: contents: readat the root of the workflow (abovejobs:) or inside thebuild:job itself. In this case, we will add it at the root for clarity and to cover any future jobs. No additional methods, imports, or dependencies are needed; simply insert the necessary YAML block.Suggested fixes powered by Copilot Autofix. Review carefully before merging.