Skip to content

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#107

Merged
Aasyaco merged 3 commits into__main__from
fix
May 3, 2026
Merged

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#107
Aasyaco merged 3 commits into__main__from
fix

Conversation

@Aasyaco
Copy link
Copy Markdown
Contributor

@Aasyaco Aasyaco commented May 3, 2026

Potential fix for https://github.com/zrsx/pycdc/security/code-scanning/3

Add an explicit permissions block to the workflow with least privilege needed.
Best fix here: define workflow-level permissions right after the trigger section and before jobs, setting:

  • contents: read (needed for checkout)
  • packages: read (safe minimal read permission often recommended; does not grant write)

This preserves existing functionality while ensuring GITHUB_TOKEN is explicitly restricted.

File to edit: .github/workflows/msvc-ci.yml
Region: between line 7 (workflow_dispatch:) and line 9 (jobs:).
No imports, methods, or additional definitions are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Summary by Sourcery

Restrict default GitHub Actions token permissions in CI workflows to address security scanning alerts.

Bug Fixes:

  • Constrain GitHub Actions workflow permissions to least privilege to resolve a code scanning warning about missing permissions configuration.

CI:

  • Add explicit least-privilege permissions blocks to the Windows, Linux, and macOS CI workflows, limiting the GITHUB_TOKEN to read-only access where required.

Summary by CodeRabbit

  • Chores
    • Added explicit permission configurations to CI/CD workflows for Linux, macOS, and MSVC pipelines.

…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c66c4f8-3222-4ff7-afb9-951d1d19260a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 3, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR tightens GitHub Actions security by adding explicit least-privilege permissions blocks at the workflow level for the MSVC, Linux, and macOS CI workflows, restricting the default GITHUB_TOKEN access to read-only scopes needed by the jobs.

Flow diagram for a CI workflow using restricted permissions

flowchart LR
  A["Trigger\n(push to __main__ or workflow_dispatch)"] --> B["Load workflow\nmsvc-ci.yml"]
  B --> C["Apply workflow-level permissions\ncontents: read\npackages: read"]
  C --> D["Job build runs on windows-latest"]
  D --> E["Actions use GITHUB_TOKEN\n(read-only contents, packages)"]
Loading

File-Level Changes

Change Details Files
Add explicit least-privilege workflow permissions to MSVC CI pipeline.
  • Define a top-level permissions block after the on triggers and before jobs in the MSVC CI workflow.
  • Grant contents: read so the workflow can use actions/checkout safely.
  • Grant packages: read to allow read-only access to GitHub Packages without write capabilities.
.github/workflows/msvc-ci.yml
Add explicit read-only workflow permissions to Linux CI pipeline.
  • Insert a top-level permissions block after the on section and before jobs in the Linux CI workflow.
  • Set contents: read to limit GITHUB_TOKEN to read-only repository contents.
.github/workflows/linux-ci.yml
Add explicit read-only workflow permissions to macOS CI pipeline.
  • Insert a top-level permissions block after the on section and before jobs in the macOS CI workflow.
  • Set contents: read to restrict GITHUB_TOKEN to read-only repository contents.
.github/workflows/macos-ci.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Aasyaco and others added 2 commits May 3, 2026 20:47
…n permissions

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Aasyaco Aasyaco marked this pull request as ready for review May 3, 2026 14:49
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • You’ve added packages: read only to the MSVC workflow but not to the Linux/macOS workflows; if they use actions/setup-python, container images, or other package-related features, consider aligning permissions across all three workflows for consistency and to avoid subtle permission issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You’ve added `packages: read` only to the MSVC workflow but not to the Linux/macOS workflows; if they use `actions/setup-python`, container images, or other package-related features, consider aligning permissions across all three workflows for consistency and to avoid subtle permission issues.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Aasyaco
Copy link
Copy Markdown
Contributor Author

Aasyaco commented May 3, 2026

@sourcery-ai You’ve added packages: read only to the MSVC workflow but not to the Linux/macOS workflows; if they use actions/setup-python, container images, or other package-related features, consider aligning permissions across all three workflows for consistency and to avoid subtle permission issues.

@Aasyaco Aasyaco merged commit 8e5a92d into __main__ May 3, 2026
23 checks passed
@Aasyaco Aasyaco deleted the fix branch May 3, 2026 15:14
@Aasyaco Aasyaco added enhancement New feature or request github_actions Pull requests that update GitHub Actions code labels May 6, 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 github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant