Skip to content

Potential fix for code scanning alert no. 13: Workflow does not contain permissions#867

Merged
Dargon789 merged 1 commit intomainfrom
alert-autofix-13
Mar 6, 2026
Merged

Potential fix for code scanning alert no. 13: Workflow does not contain permissions#867
Dargon789 merged 1 commit intomainfrom
alert-autofix-13

Conversation

@Dargon789
Copy link
Owner

@Dargon789 Dargon789 commented Mar 6, 2026

Potential fix for https://github.com/Dargon789/google-cloud-node/security/code-scanning/13

In general, the fix is to add an explicit permissions: block to the workflow or to the specific job, granting only the scopes required for the job’s operations. This constrains the GITHUB_TOKEN to the minimal privileges needed and documents those needs.

For this specific workflow, the update-api-list job needs to be able to create/update branches and open pull requests via googleapis/code-suggester@v5. That requires write permission to repository contents and pull requests. The earlier steps (checkout, setup-node, npm install, npm run generate) only need read access to repository contents (and whatever the custom script does with GITHUB_TOKEN, which is typically repo-level). A minimal and functional permission set at the job level is therefore:

permissions:
  contents: write
  pull-requests: write

You should add this block under update-api-list: and above runs-on: in .github/workflows/update-api-list.yaml. No additional imports or methods are required; this is purely a YAML configuration change and does not alter the functional behavior of the job, other than constraining token permissions.

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

Summary by Sourcery

CI:

  • Add explicit write permissions for contents and pull requests to the update-api-list GitHub Actions job to satisfy code scanning requirements.

@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds explicit minimal GITHUB_TOKEN permissions to the update-api-list GitHub Actions job to satisfy code scanning/security requirements without changing job behavior.

File-Level Changes

Change Details Files
Constrain the GITHUB_TOKEN permissions for the update-api-list GitHub Actions job to the minimal required scopes.
  • Add a permissions block at the job level for update-api-list
  • Grant contents: write so the workflow can create/update branches and push changes
  • Grant pull-requests: write so the workflow can open and update pull requests via googleapis/code-suggester
.github/workflows/update-api-list.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@snyk-io
Copy link

snyk-io bot commented Mar 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
🔚 Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@Dargon789 Dargon789 marked this pull request as ready for review March 6, 2026 12:15
@Dargon789 Dargon789 marked this pull request as draft March 6, 2026 12:16
@Dargon789 Dargon789 marked this pull request as ready for review March 6, 2026 12:16
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
@Dargon789 Dargon789 merged commit 5a58794 into main Mar 6, 2026
4 of 16 checks passed
@Dargon789 Dargon789 deleted the alert-autofix-13 branch March 6, 2026 13:00
Dargon789 pushed a commit that referenced this pull request Mar 6, 2026
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