Skip to content

fix: add explicit permissions to GitHub Actions workflow jobs#401

Merged
MaStr merged 2 commits into
mainfrom
copilot/fix-code-scanning-alerts
Jul 21, 2026
Merged

fix: add explicit permissions to GitHub Actions workflow jobs#401
MaStr merged 2 commits into
mainfrom
copilot/fix-code-scanning-alerts

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

GitHub Actions jobs in three workflows were running without explicit permissions blocks, leaving them subject to potentially over-broad default GITHUB_TOKEN permissions (read-write on older repos/orgs).

Changes

All affected jobs only need to read repo contents; Docker Hub pushes use external secrets and don't require any GITHUB_TOKEN write scope.

  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read  # added — was missing entirely

Fixes CodeQL alerts #1, #2, #5, #50 (actions/missing-workflow-permissions).
Adds 'permissions: contents: read' to each job to restrict GITHUB_TOKEN
scope and follow the principle of least privilege.
Copilot AI changed the title [WIP] Fix code scanning alerts #1, #2, #5, and #50 fix: add explicit permissions to GitHub Actions workflow jobs Jul 21, 2026
Copilot finished work on behalf of MaStr July 21, 2026 09:32
Copilot AI requested a review from MaStr July 21, 2026 09:32
@MaStr
MaStr marked this pull request as ready for review July 21, 2026 09:33
Copilot AI review requested due to automatic review settings July 21, 2026 09:33
@MaStr
MaStr merged commit 3276a0d into main Jul 21, 2026
14 checks passed
@MaStr
MaStr deleted the copilot/fix-code-scanning-alerts branch July 21, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the repository’s GitHub Actions security posture by explicitly scoping GITHUB_TOKEN permissions on jobs that only need to read repository contents, avoiding reliance on potentially broader default permissions.

Changes:

  • Added permissions: contents: read to the test job in pytest.yml.
  • Added permissions: contents: read to the lint job in pylint.yml.
  • Added permissions: contents: read to both build and merge jobs in docker-image.yml.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
.github/workflows/docker-image.yml Restricts token permissions for Docker build/merge jobs to read-only repo access.
.github/workflows/pylint.yml Restricts token permissions for the lint job to read-only repo access.
.github/workflows/pytest.yml Restricts token permissions for the test job to read-only repo access.

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.

3 participants