Skip to content

Potential fix for code scanning alert no. 4: Workflow does not contain permissions#412

Merged
lolo101 merged 1 commit intomasterfrom
alert-autofix-4
Jan 4, 2026
Merged

Potential fix for code scanning alert no. 4: Workflow does not contain permissions#412
lolo101 merged 1 commit intomasterfrom
alert-autofix-4

Conversation

@lolo101
Copy link
Owner

@lolo101 lolo101 commented Jan 4, 2026

Potential fix for https://github.com/lolo101/MsgViewer/security/code-scanning/4

In general, the fix is to explicitly declare a minimal permissions block for the workflow or for the specific job so that the GITHUB_TOKEN is limited to only what this workflow needs. Since this workflow appears to only check out code and run Qodana (a static analysis tool) without modifying the repository, contents: read is a suitable minimal set of permissions.

The best fix without changing functionality is to add a top-level permissions: block, just below the name: line and above on: in .github/workflows/code_quality.yml. This will apply to all jobs in the workflow (currently just qodana) and ensure that the GITHUB_TOKEN only has read access to repository contents. No imports or other definitions are needed, since this is purely a YAML configuration change for GitHub Actions.

Specifically, in .github/workflows/code_quality.yml, insert:

permissions:
  contents: read

between line 1 (name: Qodana) and line 2 (on:). No other changes are required.

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>
@lolo101 lolo101 marked this pull request as ready for review January 4, 2026 22:26
@lolo101 lolo101 merged commit f86b9ce into master Jan 4, 2026
6 checks passed
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