Skip to content

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

Merged
atoomic merged 1 commit intomasterfrom
alert-autofix-2
Mar 3, 2026
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#279
atoomic merged 1 commit intomasterfrom
alert-autofix-2

Conversation

@atoomic
Copy link
Contributor

@atoomic atoomic commented Mar 3, 2026

Potential fix for https://github.com/cpanel/Test-MockFile/security/code-scanning/2

In general, this problem is fixed by adding an explicit permissions block to the workflow or to each job, limiting the GITHUB_TOKEN to the least privileges required. For a workflow that only checks out code and runs tests, contents: read is typically sufficient.

The best fix here without changing existing functionality is to define a workflow-level permissions block just under the name: (and before on:), setting contents: read. This will apply to all jobs (ubuntu and perl) since neither currently defines its own permissions block, and both only need to read repository contents via actions/checkout@v4. No other scopes (such as pull-requests, issues, or packages) are required by the given steps.

Concretely, in .github/workflows/testsuite.yml, insert:

permissions:
  contents: read

between line 1 (name: testsuite) and line 3 (on:). No imports or additional definitions are needed.

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>
@atoomic atoomic marked this pull request as ready for review March 3, 2026 02:24
@atoomic atoomic merged commit 587f1b2 into master Mar 3, 2026
38 checks passed
@atoomic atoomic deleted the alert-autofix-2 branch March 3, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant