Skip to content

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

Merged
lcn2 merged 1 commit intomasterfrom
alert-autofix-5
Feb 20, 2026
Merged

Potential fix for code scanning alert no. 5: Workflow does not contain permissions#197
lcn2 merged 1 commit intomasterfrom
alert-autofix-5

Conversation

@lcn2
Copy link
Owner

@lcn2 lcn2 commented Feb 20, 2026

Potential fix for https://github.com/lcn2/calc/security/code-scanning/5

In general, the problem is fixed by explicitly declaring a permissions block that limits the GITHUB_TOKEN to the minimum needed. Since this workflow only checks out code and runs local build commands, it does not need write access to repository contents or other scopes, so contents: read at the workflow or job level is sufficient.

The best fix without changing existing functionality is to add a top‑level permissions section (aligned with name and on) that sets contents: read. This applies to all jobs in the workflow and matches the CodeQL suggestion for a minimal starting point. No existing steps need to change, and no extra permissions (like pull-requests: write) are required based on the shown snippet.

Concretely, in .github/workflows/test.yml, between the name: C CI line and the on: block, insert:

permissions:
  contents: read

No imports, methods, or other code constructs are needed since this is a YAML configuration change only.

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>
@lcn2 lcn2 marked this pull request as ready for review February 20, 2026 06:44
@lcn2 lcn2 merged commit 9dc957d into master Feb 20, 2026
4 checks passed
@lcn2 lcn2 deleted the alert-autofix-5 branch February 20, 2026 06:44
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