Skip to content

Move CodeQL security-events permission to job level for better security#33

Draft
trask with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-32
Draft

Move CodeQL security-events permission to job level for better security#33
trask with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-32

Conversation

Copilot AI commented Jul 9, 2025

Copy link
Copy Markdown

This PR fixes the CodeQL workflow permissions to follow GitHub security best practices by moving the security-events: write permission from the workflow level to the job level.

Changes Made

  • Moved security-events: write permission from workflow-level to job-level in .github/workflows/codeql-analysis.yml
  • Kept contents: read at workflow level (needed for checkout action)

Before

permissions:
  security-events: write
  contents: read

jobs:
  CodeQL-Build:
    runs-on: ubuntu-latest

After

permissions:
  contents: read

jobs:
  CodeQL-Build:
    runs-on: ubuntu-latest
    permissions:
      security-events: write

Why This Change?

This change follows the principle of least privilege by scoping the security-events: write permission only to the specific job that needs it (the one running github/codeql-action/analyze), rather than making it available to the entire workflow.

This pattern is already correctly implemented in the ossf-scorecard.yml workflow, and now both workflows that perform code scanning follow the same secure configuration.

Fixes #32.


💡 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.

Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot AI changed the title [WIP] Ensure correct CodeQL workflow permissions Move CodeQL security-events permission to job level for better security Jul 9, 2025
Copilot AI requested a review from trask July 9, 2025 23:52
Copilot finished work on behalf of trask July 9, 2025 23:52
Comment thread .github/workflows/codeql-analysis.yml
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.

Ensure correct CodeQL workflow permissions

2 participants