Skip to content

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

Merged
akabarki76 merged 1 commit intocanaryfrom
alert-autofix-88
Jun 25, 2025
Merged

Potential fix for code scanning alert no. 88: Workflow does not contain permissions#4
akabarki76 merged 1 commit intocanaryfrom
alert-autofix-88

Conversation

@akabarki76
Copy link
Copy Markdown
Member

Potential fix for https://github.com/AKA-NETWORK/next.js/security/code-scanning/88

To fix the issue, we will add a permissions block to the root of the workflow. This block will define the minimal permissions required for the workflow to function correctly. Specifically:

  • contents: read is needed for the actions/checkout step to read the repository contents.
  • pull-requests: write is required for the step that creates pull requests.

This change ensures that the GITHUB_TOKEN is scoped to the least privileges necessary, adhering to the principle of least privilege.


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

…in permissions

Below is a minimal fix to satisfy GitHub’s requirement for explicit token permissions. Add a top-level `permissions` block—here we give only read access to repo contents, which is enough for a simple pre-compile check.

```yaml
name: Check Precompiled

on:
  pull_request:
    branches:
      - canary
      - main
      - patch*
  workflow_dispatch:

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# Required: explicitly scope the GITHUB_TOKEN
permissions:
  contents: read
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup Node.js 20
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install deps
        run: pnpm install --frozen-lockfile

      - name: Run pre-compiled check
        run: ./scripts/check-pre-compiled.sh
```

—  
Additional tips:

• If you ever need to write status comments or push tags, add `contents: write` (or more granular scopes).  
• For workflows calling external registries, you may need `packages: write`.  
• To use OpenID Connect (OIDC) in a later step, add `id-token: write`.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Mustapha BARKI <code4yo@gmail.com>
@akabarki76 akabarki76 marked this pull request as ready for review June 25, 2025 14:10
@akabarki76 akabarki76 merged commit d441bf3 into canary Jun 25, 2025
10 of 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.

1 participant