Skip to content

Conversation

@cinderellasecure
Copy link
Contributor

@cinderellasecure cinderellasecure commented Oct 29, 2025

As part of the organization's transition to default read-only permissions for the GITHUB_TOKEN, this pull request addresses a missing permission in the workflow that triggered a code scanning alert.

This PR explicitly adds the required read permissions to align with the default read only permission and is part of a larger effort for this OKR https://github.com/github/security-services/issues/455

Potential fixes for 2 code scanning alerts from the Copilot AutoFix: Missing Permissions in Workflows security campaign:

  • https://github.com/github/custom-element-boilerplate/security/code-scanning/2
    To address the CodeQL warning and follow security best practices, an explicit permissions block should be added specifying the minimal required privileges. Since the shown job only checks out code and publishes to npm (with authentication via NODE_AUTH_TOKEN), the only required privilege for the GITHUB_TOKEN is likely contents: read. This fix involves adding a permissions: block at the workflow root (to cover all jobs) or within the specific job that needs it. The best location is the top of the file, after the name and before on:, or just after on: and before jobs:.

    Implementation Steps:

    • Insert the following block near the top of .github/workflows/publish.yml (after the name: and before on: or directly after on:):
    permissions:
    contents: read
    • No other changes are necessary unless further job steps (not shown) require additional permissions.
  • https://github.com/github/custom-element-boilerplate/security/code-scanning/1
    The best way to fix the issue is to add a permissions block to the workflow or the specific job(s) within the workflow. Since the job appears to only be building and testing code (checkout and setup-node, then npm commands), it does not require write access to repository resources, so setting contents: read at the job level is sufficient and aligns with GitHub's recommended minimum. This can be done by adding a permissions: block under the build: job, above runs-on: macos-latest.

    No new methods or imports are required; this is a YAML structural edit.


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

cinderellasecure and others added 2 commits October 29, 2025 13:02
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cinderellasecure cinderellasecure marked this pull request as ready for review October 29, 2025 19:02
@cinderellasecure cinderellasecure requested a review from a team as a code owner October 29, 2025 19:02
Copilot AI review requested due to automatic review settings October 29, 2025 19:02
Copy link

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

This PR implements security hardening for GitHub Actions workflows by adding explicit permissions configurations to follow the principle of least privilege.

  • Added job-level contents: read permission to the test workflow
  • Added workflow-level contents: read permission to the publish workflow

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/test.yml Added job-level permissions restricting the build job to read-only access
.github/workflows/publish.yml Added workflow-level permissions restricting all jobs to read-only access

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

name: Publish

permissions:
contents: read
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The publish workflow needs write permissions to publish packages but is only granted read access. This will likely cause the npm publish step to fail. Consider adding contents: write or moving the permissions to job-level where the publish-npm job has appropriate write permissions.

Suggested change
contents: read
contents: write

Copilot uses AI. Check for mistakes.
@TylerJDev
Copy link
Contributor

Thanks for the PR @cinderellasecure!

@TylerJDev TylerJDev merged commit d2b7a39 into main Oct 30, 2025
12 checks passed
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.

3 participants