KEMBAR78
Add explicit permissions to GitHub Actions workflows to fix CodeQL warnings by Copilot · Pull Request #3648 · microsoft/windows-rs · GitHub
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 1, 2025

This PR addresses CodeQL warnings about missing workflow permissions by adding explicit permissions sections to all GitHub Actions workflows in the repository.

Problem

CodeQL was generating warnings for workflows that didn't have explicit permissions defined, as they were using default permissions which can be overly broad and don't follow the principle of least privilege.

Solution

Added permissions: contents: read to all workflow files, which provides the minimal required permissions for workflows that need to checkout code and run builds/tests.

Changes Made

Generated Workflows (via yml tool):

  • Updated workflow generators in crates/tools/yml/src/:
    • test.rs - generates test.yml
    • clippy.rs - generates clippy.yml
    • msrv.rs - generates msrv.yml
    • no_default_features.rs - generates no-default-features.yml
  • Regenerated corresponding YAML files with permissions

Manual Workflows:

  • Added permissions to manually maintained workflows:
    • fmt.yml, lib.yml, gen.yml, no_std.yml
    • slim_errors.yml, linux.yml, miri.yml
    • doc.yml, cross.yml

Existing workflows (stale.yml, web.yml) already had appropriate permissions defined.

Result

  • All 15 workflow files now have explicit permissions defined
  • Follows principle of least privilege with minimal contents: read permission
  • Maintains existing functionality while addressing security best practices
  • Generated files remain consistent with the repository's workflow generation system

The changes are minimal and surgical - adding only 3 lines per workflow file while maintaining all existing functionality.

Fixes #3647.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits July 1, 2025 15:36
Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
Copilot AI changed the title [WIP] Deal with CodeQL warnings related to workflow permissions Add explicit permissions to GitHub Actions workflows to fix CodeQL warnings Jul 1, 2025
Copilot AI requested a review from kennykerr July 1, 2025 15:41
Copilot finished work on behalf of kennykerr July 1, 2025 15:41
@kennykerr
Copy link
Collaborator

Fix the new nightly Clippy warning in a separate PR.

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

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

Fix the new nightly Clippy warning in a separate PR.

@kennykerr kennykerr marked this pull request as ready for review July 1, 2025 18:03
@kennykerr
Copy link
Collaborator

Closing as unnecessary as the defaults are already set to read-only.

@kennykerr kennykerr closed this Jul 1, 2025
@kennykerr kennykerr deleted the copilot/fix-3647 branch July 2, 2025 15:05
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.

Deal with CodeQL warnings related to workflow permissions

2 participants