Skip to content

Only request read permission for PR scan#16295

Open
AlanCoding wants to merge 1 commit intoansible:develfrom
AlanCoding:read_only
Open

Only request read permission for PR scan#16295
AlanCoding wants to merge 1 commit intoansible:develfrom
AlanCoding:read_only

Conversation

@AlanCoding
Copy link
Member

@AlanCoding AlanCoding commented Feb 18, 2026

SUMMARY

attempted fix for the approval button

Screenshot From 2026-02-18 15-16-22
ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

Note

Low Risk
CI workflow permission tightening only; no product code or data-handling logic is affected.

Overview
Reduces the pr_body_check.yml GitHub Actions workflow permissions by changing packages: write to packages: read, keeping contents: read unchanged.

Written by Cursor Bugbot for commit 37bb2c6. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Chores
    • Reduced CI workflow permission for package operations from write to read.
    • Confirmed no other workflow steps or control flow were changed; minimal configuration tweak to tighten permissions.

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

The GitHub Actions workflow .github/workflows/pr_body_check.yml had its permissions.packages scope changed from write to read; no other workflow steps or permissions were modified.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/pr_body_check.yml
Adjusted permissions.packages from write to read. No other changes to steps or control flow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly summarizes the main change: reducing GitHub Actions workflow permissions for the PR scan from write to read access.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@AlanCoding
Copy link
Member Author

didn't work

Screenshot From 2026-02-18 15-22-37

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.github/workflows/pr_body_check.yml (1)

14-16: packages: read is still over-scoped — the permission can be dropped entirely.

No step in this workflow interacts with GitHub Packages (no container pulls/pushes, no package publishing). The packages entry can be removed rather than downgraded. That said, changing it from write to read is the correct direction and resolves the fork-PR approval gate described in the PR.

♻️ Proposed cleanup
     permissions:
-      packages: read
       contents: read
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr_body_check.yml around lines 14 - 16, The workflow's
permissions block is still granting packages: read unnecessarily; remove the
packages line entirely from the permissions block so only required permissions
remain (e.g., keep contents: read if needed). Locate the permissions block (the
"permissions:" mapping and the "packages:" key) and delete the "packages: read"
entry, ensuring YAML remains valid and other permission keys like "contents:
read" are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/pr_body_check.yml:
- Around line 14-16: The workflow's permissions block is still granting
packages: read unnecessarily; remove the packages line entirely from the
permissions block so only required permissions remain (e.g., keep contents: read
if needed). Locate the permissions block (the "permissions:" mapping and the
"packages:" key) and delete the "packages: read" entry, ensuring YAML remains
valid and other permission keys like "contents: read" are preserved.

@AlanCoding
Copy link
Member Author

@TheRealHaoLiu TheRealHaoLiu enabled auto-merge (squash) February 18, 2026 20:32
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/pr_body_check.yml:
- Around line 14-16: The workflow declares an unused permissions block (the keys
`permissions`, `packages`, and `contents`) even though the job only reads `${{
github.event.pull_request.body }}` and never uses `actions/checkout` or package
registries; remove the entire `permissions:` block (or leave it present but
empty) from the workflow to eliminate unnecessary scopes (`packages: read`,
`contents: read`) and keep the workflow minimal.

Comment on lines 14 to 16
permissions:
packages: write
packages: read
contents: read
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat .github/workflows/pr_body_check.yml

Repository: ansible/awx

Length of output: 1512


🏁 Script executed:

#!/bin/bash
# Check whether any step in the workflow references GITHUB_TOKEN with packages scope
# or calls any GitHub Packages API/registry endpoint.
rg -n "packages\|ghcr\.io\|pkg\.github\.com\|npm\.pkg\.github\.com" .github/workflows/pr_body_check.yml

Repository: ansible/awx

Length of output: 37


Remove unused packages and contents permissions from the workflow

The workflow declares packages: read and contents: read, but neither is used. The rg search confirms zero references to GitHub Container Registry or package registries throughout the workflow. The only data source is ${{ github.event.pull_request.body }} (from the webhook event context), which requires no repository access. Since no actions/checkout step exists, contents: read is unnecessary.

Remove the entire permissions block or leave it empty:

Fix: drop unused permissions
-    permissions:
-      packages: read
-      contents: read

Note: The "workflow awaiting approval" banner is controlled by repository settings (Settings → Actions → Fork pull request workflows), independent of declared permission scopes. Changing packages: write to packages: read would not have resolved the approval gate.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
packages: write
packages: read
contents: read
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr_body_check.yml around lines 14 - 16, The workflow
declares an unused permissions block (the keys `permissions`, `packages`, and
`contents`) even though the job only reads `${{ github.event.pull_request.body
}}` and never uses `actions/checkout` or package registries; remove the entire
`permissions:` block (or leave it present but empty) from the workflow to
eliminate unnecessary scopes (`packages: read`, `contents: read`) and keep the
workflow minimal.

@sonarqubecloud
Copy link

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.

1 participant