Skip to content

Set appropriate permissions to all Github Actions workflows#1976

Merged
iMicknl merged 5 commits intomainfrom
fix/all_workflows_should_contain_permissions
Apr 6, 2026
Merged

Set appropriate permissions to all Github Actions workflows#1976
iMicknl merged 5 commits intomainfrom
fix/all_workflows_should_contain_permissions

Conversation

@iMicknl
Copy link
Copy Markdown
Owner

@iMicknl iMicknl commented Apr 6, 2026

Potential fix for https://github.com/iMicknl/python-overkiz-api/security/code-scanning/19

In general, the fix is to explicitly declare a permissions block in the workflow, restricting the GITHUB_TOKEN to the minimum scope required. For this test workflow, read-only access to repository contents is sufficient, so contents: read at the top level is appropriate. This documents the intended permissions, avoids accidental write access if organization defaults are broad, and applies to all jobs that do not override permissions.

The best concrete fix here is to add a root-level permissions: block just after the name: test line in .github/workflows/test.yml. This will apply contents: read to the entire workflow, including the pytest job. No existing steps need to be changed, and no additional imports or actions are required because actions/checkout and the other used actions work with read-only contents. Only this YAML file needs updating, and the change is limited to inserting the new permissions section.

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>
@github-actions github-actions bot added the bug Something isn't working label Apr 6, 2026
iMicknl and others added 3 commits April 6, 2026 22:11
…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@iMicknl iMicknl marked this pull request as ready for review April 6, 2026 20:13
@iMicknl iMicknl requested a review from tetienne as a code owner April 6, 2026 20:13
Copilot AI review requested due to automatic review settings April 6, 2026 20:13
@iMicknl iMicknl changed the title Potential fix for code scanning alert no. 19: Workflow does not contain permissions Set appropriate permissions to all Github Actions workflows Apr 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit permissions blocks to GitHub Actions workflows to address code scanning alert #19 by restricting the default GITHUB_TOKEN scope to the minimum required.

Changes:

  • Set workflow-level permissions: contents: read for test and lint workflows.
  • Set workflow-level permissions for pr-labeler to allow PR labeling while keeping repo contents read-only.
  • Add job-level permissions for release-drafter to allow updating release drafts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/test.yml Adds top-level permissions with contents: read for the test workflow.
.github/workflows/lint.yaml Adds top-level permissions with contents: read for the lint workflow.
.github/workflows/pr-labeler.yml Adds top-level permissions (contents: read, pull-requests: write) for PR labeling.
.github/workflows/release-drafter.yml Adds job-level permissions to allow release draft updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@iMicknl iMicknl merged commit 1333355 into main Apr 6, 2026
13 checks passed
@iMicknl iMicknl deleted the fix/all_workflows_should_contain_permissions branch April 6, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants