Skip to content

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

Closed
jonasbardino wants to merge 1 commit intomasterfrom
fix/permissions-on-ci-action-to-readonly
Closed

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#146
jonasbardino wants to merge 1 commit intomasterfrom
fix/permissions-on-ci-action-to-readonly

Conversation

@jonasbardino
Copy link
Contributor

Potential fix for https://github.com/ucphhpc/docker-migrid/security/code-scanning/2

To fix the issue, explicitly restrict the GITHUB_TOKEN permissions used by this workflow to the least privilege necessary. This workflow only checks out code and runs local build/test commands; it does not interact with issues, pull requests, or perform any write operations via the GitHub API. Therefore, setting contents: read at the workflow or job level is sufficient and appropriate.

The best minimal fix without changing existing behavior is:

  • Add a permissions block at the top level of the workflow (alongside name and on) so it applies to all jobs that don’t override it.
  • Set contents: read there. No other scopes appear necessary given the current steps.

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

permissions:
  contents: read

between the name: Continuous Integration line and the on: block (e.g., new line 2 and 3). No imports or additional methods are needed because 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>
Signed-off-by: Jonas Bardino <bardino@science.ku.dk>
@jonasbardino jonasbardino added the enhancement New feature or request label Mar 16, 2026
@jonasbardino
Copy link
Contributor Author

jonasbardino commented Mar 16, 2026

Closing and making the fix manually in #148 instead.

@jonasbardino jonasbardino deleted the fix/permissions-on-ci-action-to-readonly branch March 16, 2026 11:02
@jonasbardino jonasbardino self-assigned this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant