Skip to content

Potential fix for code scanning alert no. 4: Workflow does not contain permissions#22

Open
Lawrence Lucas Large (LukeLarge) wants to merge 1 commit intomainfrom
alert-autofix-55
Open

Potential fix for code scanning alert no. 4: Workflow does not contain permissions#22
Lawrence Lucas Large (LukeLarge) wants to merge 1 commit intomainfrom
alert-autofix-55

Conversation

@LukeLarge
Copy link
Copy Markdown

Potential fix for https://github.com/TLMSLLC/ton-preprocessed-wallet-v2/security/code-scanning/4

In general, fix this by explicitly setting permissions for each job (or at the workflow root) so that GITHUB_TOKEN has only the minimal required scopes. Jobs that just build and test usually only need read access to contents (and sometimes to packages); jobs that publish packages or modify repo state can request the additional write scopes they need.

For this workflow, leave the existing permissions block on publish-gpr unchanged, because it already uses contents: read and packages: write, which are appropriate for publishing to GitHub Packages. Add a new permissions block to the build job directly under its job definition (e.g., under runs-on) that restricts permissions to contents: read. This matches CodeQL’s suggested minimal starting point and does not change functional behavior for the build job, since npm ci and npm test do not require write access to the repository or other GitHub resources.

Concretely:

  • Edit .github/workflows/npm-publish-github-packages.yml.
  • Under jobs.build, add:
    permissions:
      contents: read
    aligned with the existing indentation, between runs-on: ubuntu-latest and steps:. No new imports or dependencies are required.

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>
Signed-off-by: Lawrence Lucas Large <162439255+LukeLarge@users.noreply.github.com>
@LukeLarge Lawrence Lucas Large (LukeLarge) marked this pull request as ready for review April 5, 2026 18:42
Copilot AI review requested due to automatic review settings April 5, 2026 18:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Restricts the default GITHUB_TOKEN permissions for the build job in the npm publish workflow to address code scanning alert #4 by applying least-privilege permissions.

Changes:

  • Add an explicit permissions block to jobs.build.
  • Set contents: read for the build job to avoid unnecessary write scopes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants