Skip to content

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

Closed
admdly wants to merge 1 commit intomainfrom
alert-autofix-2
Closed

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#6
admdly wants to merge 1 commit intomainfrom
alert-autofix-2

Conversation

@admdly
Copy link

@admdly admdly commented Feb 28, 2026

Potential fix for https://github.com/FOSSBilling/example-module/security/code-scanning/2

In general, the fix is to explicitly set minimal GITHUB_TOKEN permissions using a permissions block, either at the workflow root (applies to all jobs) or per job. Since both jobs in this workflow only read code and metadata (no writes to the repo, issues, or PRs), the minimal appropriate permission is contents: read.

The best fix without changing functionality is to add a root-level permissions block just under the on: section, applying to both phpstan and phpstan-release jobs. This keeps the workflow behavior unchanged while constraining the token. Specifically, in .github/workflows/php-ci.yml, after line 7 (the end of the on: triggers) and before line 9 (jobs:), insert:

permissions:
  contents: read

No imports or additional definitions are needed, as this is purely a YAML configuration change.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@admdly admdly marked this pull request as ready for review February 28, 2026 13:32
@admdly
Copy link
Author

admdly commented Feb 28, 2026

Requires further testing.

@admdly admdly closed this Feb 28, 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