Skip to content

Potential fix for code scanning alert no. 10: Workflow does not contain permissions#455

Merged
cedricfung merged 1 commit intomainfrom
alert-autofix-10
Mar 16, 2026
Merged

Potential fix for code scanning alert no. 10: Workflow does not contain permissions#455
cedricfung merged 1 commit intomainfrom
alert-autofix-10

Conversation

@cedricfung
Copy link
Contributor

Potential fix for https://github.com/MixinNetwork/bot-api-nodejs-client/security/code-scanning/10

In general, the fix is to explicitly declare permissions: in the workflow, restricting the GITHUB_TOKEN to the minimum required. If neither job needs to write to the repo or other resources via GITHUB_TOKEN, we can safely set contents: read at the workflow level and let it apply to both jobs.

The best fix here is to add a top-level permissions: block under the workflow name: (or under on:) so it applies to all jobs. Since the current workflow only checks out code, sets up Node, runs tests, and publishes to npm using a separate secret (NODE_AUTH_TOKEN), it does not require any write permissions on the repo; read-only access to contents is sufficient. We therefore set:

permissions:
  contents: read

This should be inserted between the name: Node.js Package line and the on: block (around line 5–6). No other code changes, imports, or definitions are needed, and existing functionality remains unchanged.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cedricfung cedricfung marked this pull request as ready for review March 16, 2026 08:53
@cedricfung cedricfung merged commit 2810175 into main Mar 16, 2026
5 checks passed
@cedricfung cedricfung deleted the alert-autofix-10 branch March 16, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant