Skip to content

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#1

Merged
ch-zacmo merged 1 commit into
mainfrom
alert-autofix-3
Apr 2, 2026
Merged

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#1
ch-zacmo merged 1 commit into
mainfrom
alert-autofix-3

Conversation

@ch-zacmo
Copy link
Copy Markdown
Contributor

@ch-zacmo ch-zacmo commented Apr 2, 2026

Potential fix for https://github.com/A3KSA/swisscomSendJS/security/code-scanning/3

In general, the fix is to add an explicit permissions block that grants only the minimal scopes required by this workflow. Because this workflow just checks out code, installs dependencies, runs tests, and publishes to npm (using NODE_AUTH_TOKEN), it doesn’t need write access to repository contents or other scopes. A safe and recommended baseline is permissions: contents: read at the workflow or job level.

The simplest and most consistent fix without altering functionality is to add a top‑level permissions block right after the name: and before on: so it applies to both jobs, with contents: read. This documents the intent and ensures the GITHUB_TOKEN cannot be used to push commits, create releases, etc. No additional imports or external libraries are needed; this is a pure YAML configuration change within .github/workflows/npm-publish.yml.

Specifically, in .github/workflows/npm-publish.yml, insert:

permissions:
  contents: read

between lines 5 and 6 (after name: Node.js Package and before on:). No other lines need to change.

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

…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ch-zacmo ch-zacmo marked this pull request as ready for review April 2, 2026 13:40
@ch-zacmo ch-zacmo merged commit c70ec03 into main Apr 2, 2026
5 checks passed
@ch-zacmo ch-zacmo deleted the alert-autofix-3 branch April 2, 2026 13:40
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