Skip to content

Potential fix for code scanning alert no. 5: Workflow does not contain permissions#2

Merged
majorsilence merged 1 commit intomainfrom
alert-autofix-5
Mar 19, 2026
Merged

Potential fix for code scanning alert no. 5: Workflow does not contain permissions#2
majorsilence merged 1 commit intomainfrom
alert-autofix-5

Conversation

@majorsilence
Copy link
Copy Markdown
Member

Potential fix for https://github.com/TownSuite/DapperExtras/security/code-scanning/5

In general, the fix is to add an explicit permissions block to the workflow or to the individual job(s) so that the GITHUB_TOKEN has only the minimal scopes required. For this workflow, the report job runs after tests and uses dorny/test-reporter@v2 to read an uploaded artifact and create a GitHub Check Run with the test results. That means it needs to read repository contents and write checks, but does not need broader write permissions (like pushing commits, modifying issues, etc.).

The best minimal fix without changing functionality is to add a permissions block under the report job, specifying contents: read (to align with normal read-only repo access) and checks: write (so it can create/update the test report check). We’ll insert:

    permissions:
      contents: read
      checks: write

directly under report: and above runs-on: in .github/workflows/report-tests.yml. No other files or imports are involved, and the rest of the workflow remains unchanged.

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>
@majorsilence majorsilence marked this pull request as ready for review March 19, 2026 12:30
Copilot AI review requested due to automatic review settings March 19, 2026 12:30
@majorsilence majorsilence merged commit 632b181 into main Mar 19, 2026
4 checks passed
@majorsilence majorsilence deleted the alert-autofix-5 branch March 19, 2026 12:30
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

This PR addresses code scanning alert #5 by scoping down GITHUB_TOKEN permissions in the report-tests workflow that publishes test results via dorny/test-reporter@v2.

Changes:

  • Adds an explicit job-level permissions block to the report job
  • Grants contents: read and checks: write for creating/updating the test report check run

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

- completed
jobs:
report:
permissions:
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