Skip to content

Fix for code scanning alert no. 1: Workflow does not contain permissions#7

Merged
admdly merged 9 commits intomainfrom
alert-autofix-1
Mar 8, 2026
Merged

Fix for code scanning alert no. 1: Workflow does not contain permissions#7
admdly merged 9 commits intomainfrom
alert-autofix-1

Conversation

@admdly
Copy link
Contributor

@admdly admdly commented Mar 8, 2026

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

In general, the fix is to explicitly define a permissions: block that grants only the minimal required access to the GITHUB_TOKEN. For this workflow, both jobs only need to read repository contents and tags/releases. They do not need to push commits, modify PRs, or interact with issues. Therefore, contents: read is sufficient for the entire workflow.

The best fix without changing functionality is to add a root‑level permissions: block (so it applies to all jobs) directly under the name: or on: section in .github/workflows/php-ci.yml. Set it to contents: read, which mirrors the minimal suggested by CodeQL. There is no evidence that other scopes (like pull-requests or issues) are needed, and none of the used actions document a requirement for write permissions in this use case. No additional methods, imports, or definitions are needed, since this is purely a YAML configuration change to the workflow file.

Concretely:

  • Edit .github/workflows/php-ci.yml.
  • Insert:
permissions:
  contents: read

near the top of the file at workflow scope, e.g., after the on: block (or directly after name:; either is valid). This will ensure both phpstan and phpstan-release jobs run with a read‑only GITHUB_TOKEN, resolving the CodeQL finding.

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

admdly and others added 2 commits March 8, 2026 09:34
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@admdly admdly changed the title Potential fix for code scanning alert no. 1: Workflow does not contain permissions Fix for code scanning alert no. 1: Workflow does not contain permissions Mar 8, 2026
@admdly admdly marked this pull request as ready for review March 8, 2026 10:01
@admdly admdly merged commit 56f6ff4 into main Mar 8, 2026
2 of 4 checks passed
@admdly admdly deleted the alert-autofix-1 branch March 8, 2026 10:15
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