Potential fixes for 2 code scanning alerts #80
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.
Potential fixes for 2 code scanning alerts
https://github.com/github/text-expander-element/security/code-scanning/4
To address the problem, add an explicit
permissions:key to restrict the GITHUB_TOKEN in the workflow. This is most effective when added at the workflow root, applying it to all jobs unless individually overridden. The minimal recommended setting iscontents: read, which is sufficient unless the workflow (or specific job steps) truly requires additional permissions. In the provided workflow, publishing to npm usesNODE_AUTH_TOKENfrom secrets and does not require GITHUB_TOKEN write access, socontents: readis the safest starting point. The edit should occur at the root of the workflow, for instance between thename:andon:keys. No additional imports or external dependencies are needed.https://github.com/github/text-expander-element/security/code-scanning/3
To fix the issue, add a
permissionsblock specifying the minimal required privileges for the job. Since the workflow installs dependencies, runs a build, and tests, but does not write to the repository or perform operations requiring more privileges,contents: readis sufficient. Place the block at the job-level (build:job) since the job is flagged, or alternatively at the workflow root to cover all jobs. In this case, adding it under thebuild:job is clear and direct.Edit
.github/workflows/nodejs.ymland insert:immediately after the job name (
build:), beforeruns-on:.No additional methods, imports, or dependencies are needed.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.