Skip to content

chore(MSDK-4510): Set default read-only permissions in claude workflow - #265

Merged
luislino-uc merged 1 commit into
masterfrom
chore/MSDK-4510-claude-workflow-default-read-permissions
Nov 12, 2026
Merged

luislino-uc merged 1 commit into
masterfrom
chore/MSDK-4510-claude-workflow-default-read-permissions

Conversation

@luislino-uc

@luislino-uc luislino-uc commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

User description

Summary

  • Adds a top-level permissions: contents: read to .github/workflows/claude.yml, so any job without its own block defaults to read-only.
  • The claude job keeps its existing job-level permissions (contents, pull-requests, id-token write; actions read), which claude-code-action needs. No behaviour change for the integration.

Addresses the Apiiro / Checkov finding CKV2_GHA_1 ("Ensure top-level permissions are not set to write-all") tracked in MSDK-4510.

Notes

  • The workflow had no top-level permissions block before and no write-all anywhere; the finding points at the job-level block (line 34). This change is least-privilege hardening and is expected to satisfy a top-level check, but Checkov was not run locally, so please confirm in Apiiro after merge.
  • The workflow only runs on PR comments mentioning @claude, so it was not exercised in CI here. YAML parses correctly.

🤖 Generated with Claude Code


CodeAnt-AI Description

Set read-only default permissions for the Claude workflow

What Changed

  • Workflow jobs without their own permissions now default to read-only access to repository contents
  • The Claude job keeps its existing permissions

Impact

✅ Reduced default workflow write access
✅ Claude workflow permissions remain unchanged

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Chores
    • Updated automation permission defaults to use more limited access, while retaining the permissions required for its existing tasks.
    • No changes to user-facing features or behavior.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #36cfc Reviewed your PR 65c8137 Nov 12, 2026 · 14:51 14:51

@codeant-ai

codeant-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The workflow now sets contents: read as the default permission. The claude job retains its explicit permissions, including contents: write.

Changes: Workflow Permissions

Layer / File(s) Summary
Set workflow-level contents permission
.github/workflows/claude.yml
The workflow declares contents: read as the default permission. The claude job's explicit permissions remain unchanged.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Suggested reviewers: islameldesoky95

Merge Risk: Minimal · up to 65c81

This hardens the workflow's default token permissions to read-only without changing how the @claude integration behaves. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: it sets default read-only permissions in the claude workflow. The raw summary and PR objectives confirm that a top-level contents: read permission was added to .github/work…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: it sets default read-only permissions in the claude workflow. The raw summary and PR objectives confirm that a top-level contents: read permission was added to .github/workflows/claude.yml, and the claude job keeps its own write permissions. The title uses a conventional commit prefix and a ticket ID, which is acceptable. It is specific and matches the primary change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59ce7e62-3aff-4646-926a-8e613a613bf8
Commits

Reviewing files that changed from the base of the PR and between 75617e7 and 65c8137.

Files selected for processing: 1

  • .github/workflows/claude.yml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Default Claude workflow permissions to read-only

⚙️ Configuration changes 🕐 Less than 5 minutes

Grey Divider

AI Description

• Default workflow token permissions to read-only for jobs without explicit permissions.
• Preserve the Claude job’s existing permissions so its integration can continue to operate.
High-Level Assessment

A read-only workflow default with an explicit job-level override is the appropriate least-privilege approach. Confirm separately that Apiiro clears the finding, since Checkov was not run locally.

Files changed (1) +4 / -0

Other (1) +4 / -0
claude.ymlSet read-only default token permissions +4/-0

Set read-only default token permissions

• Adds workflow-level 'contents: read' permissions for jobs without their own permissions block. The Claude job retains its existing job-level permissions.

.github/workflows/claude.yml

@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Nov 12, 2026
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Informational

1. Workflow hardening leaves the Claude job's write scopes unchanged 🐞 Bug ⛨ Security
Description
The new top-level permissions: contents: read block is fully overridden by the claude job's own
permissions: block, which still grants contents: write, pull-requests: write and `id-token:
write`. The change therefore only protects jobs added later that omit their own permissions, and
does not reduce the privileges of the job that runs on @claude comments.
Code

.github/workflows/claude.yml[R11-14]

+# Default to read-only for any job; the claude job below declares what it needs.
+permissions:
+  contents: read
+
Evidence
In GitHub Actions, a job-level permissions block replaces the workflow-level default rather than
merging with it. The claude job declares its own block with contents: write, `pull-requests:
write, id-token: write and actions: read`, so the new top-level block has no effect on that job.

.github/workflows/claude.yml[11-14]
.github/workflows/claude.yml[34-39]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
The new top-level read-only permissions block is overridden by the claude job's job-level permissions block, which still grants write scopes. Confirm which scopes claude-code-action truly needs, then narrow the job-level block accordingly, or document that the Checkov finding is a false positive.

Fix Focus Areas
- .github/workflows/claude.yml[11-14]
- .github/workflows/claude.yml[34-39]

Recommended Fix
Keep the top-level `contents: read` block. In the `claude` job, review whether `contents: write`, `pull-requests: write` and `id-token: write` are each required by claude-code-action, and drop any that are not. Re-check the finding in Apiiro after merge and update the PR description to match what the change actually does.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
Review mode: Auto: 🚀 Fast: Localized workflow permission hardening with one small, self-contained edit.

Grey Divider

Tip of the day
💡 Did you know, you can open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread .github/workflows/claude.yml Resolved
@codeant-ai

codeant-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 65c8137b1056

@pantoaibot

pantoaibot Bot commented Nov 12, 2026

Copy link
Copy Markdown

PR Summary:

Set repository-level default permissions to read-only in the Claude workflow; the claude job still overrides and grants the specific write scopes it requires.

  • Added top-level permissions block (contents: read) and explanatory comment to .github/workflows/claude.yml so jobs default to read-only.
  • claude job explicitly continues to set required permissions: contents: write, pull-requests: write, id-token: write, actions: read.
  • No changes to triggering conditions, concurrency, timeout, or steps — behavior and flow remain the same.
  • Security improvement: reduces action token privileges by default (least-privilege); no breaking changes expected.

Reviewed by Panto AI

Comment thread .github/workflows/claude.yml Resolved
@pantoaibot

pantoaibot Bot commented Nov 12, 2026

Copy link
Copy Markdown

Reviewed up to commit:65c8137b10568f42550b89c98ed6b7a2c6e80ff1

Additional Suggestion
Others - Add a brief comment in the PR or directly above the top-level permissions block stating the intent and the tracked ticket (MSDK-4510) and rule being addressed (e.g. CKV2_GHA_1). This helps future reviewers understand why the default was tightened and avoids accidental reversion.
# Default to read-only for any job; tightened per MSDK-4510 to satisfy CKV2_GHA_1.
permissions:
  contents: read

Reviewed by Panto AI

@luislino-uc
luislino-uc merged commit 71060b4 into master Nov 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants