Skip to content

CNTRLPLANE-3677: address-review-pr: add author authorization check - #590

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift-eng:mainfrom
enxebre:address-review-pr-author-authorization
Jul 6, 2026
Merged

openshift-merge-bot[bot] merged 2 commits into
openshift-eng:mainfrom
enxebre:address-review-pr-author-authorization

Conversation

@enxebre

@enxebre enxebre commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add check_authorized.py script that verifies PR comment authors against OWNERS, OWNERS_ALIASES, approved bots, and org membership before processing their feedback
  • Update the skill's Step 0.5 to invoke the script deterministically instead of describing authorization logic in prose
  • Prevents untrusted actors from instructing the agent to make changes via review comments

This replicates the authorization logic from the review-agent comment_analyzer.py as a standalone reusable script.

Test plan

  • check_authorized.py openshift hypershift enxebre → authorized (owners), exit 0
  • check_authorized.py openshift hypershift 'coderabbitai[bot]' → authorized (approved_bot), exit 0
  • check_authorized.py openshift hypershift random-attacker-user → not authorized, exit 1
  • check_authorized.py openshift hypershift openshift-ci-robot → ignored bot, exit 1

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an “Author Authorization” gate for PR review commentary, ensuring only approved commenters are considered.
    • Improved authorization handling by caching checks to reduce repeated lookups.
  • Bug Fixes
    • Silently exclude unauthorized authors’ comments from downstream processing.
    • If authorization cannot be verified, affected comments are skipped instead of disrupting review handling.
  • Documentation
    • Documented the PyYAML prerequisite for parsing repository OWNERS files.
  • Chores
    • Updated the plugin release version to 1.1.7.

@openshift-ci
openshift-ci Bot requested review from dgoodwin and stbenjam June 30, 2026 12:57
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

A new authorization check is added for review-comment authors, and the review skill now uses it before processing comments. The plugin version is updated to 1.1.7 in both manifest and marketplace metadata.

Changes

Author authorization flow

Layer / File(s) Summary
Authorization script
plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py, plugins/openshift-developer/README.md
Adds the CLI contract, OWNERS/OWNERS_ALIASES parsing, org membership fallback, JSON exit handling, and the PyYAML prerequisite.
Skill authorization gate
plugins/openshift-developer/skills/address-review-pr/SKILL.md
Adds Step 0.5 author authorization, caches per-author checks, and filters out unauthorized authors before later processing.

Plugin version metadata

Layer / File(s) Summary
Version bump
plugins/openshift-developer/.claude-plugin/plugin.json, docs/index.html
Bumps the openshift-developer version from 1.1.6 to 1.1.7 in both metadata locations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: lgtm

Suggested reviewers: cblecker, theobarberbany


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Git Push Safety Rules ❌ Error SKILL.md now instructs an unconditional git push in Step 4b, with no user confirmation before pushing. Add an explicit user-approval gate before any push, or remove the push step from the skill; never allow autonomous push instructions.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding an author authorization check for address-review-pr.
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.
No Real People Names In Style References ✅ Passed Inspected changed plugin/skill docs; references are to bots/usernames and Claude Code, with no real-person style refs or example names found.
No Assumed Git Remote Names ✅ Passed The only committed change is check_authorized.py, which contains no git remote names or remote-selection commands.
No Untrusted Mcp Servers ✅ Passed The diff only adds an auth-check script and version bumps; no MCP server install commands or untrusted MCP deps are introduced.
Ai-Helpers Overlap Detection ✅ Passed Only open PR match is the PR under review itself; nearest existing ai-helpers files are low-similarity (<32%), so no >=60% overlap found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@enxebre
enxebre force-pushed the address-review-pr-author-authorization branch 2 times, most recently from 9f141e0 to 4f77060 Compare June 30, 2026 13:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py`:
- Around line 46-52: The gh subprocess calls in run_gh and the other
subprocess.run usage should not wait indefinitely. Add a bounded timeout to each
gh invocation, and in the surrounding error handling convert
subprocess.TimeoutExpired into the same documented nonzero error exit used for
other failures. Keep the fix localized to the helper that wraps gh and the later
call site so Step 0.5 fails fast instead of hanging.
- Around line 104-150: The OWNERS/OWNERS_ALIASES lookup in check_authorized.py
is swallowing real fetch/parsing errors and only printing warnings, which causes
authorized reviewers to be treated as unauthorized. Update the OWNERS_ALIASES
and OWNERS loading logic in the authorization flow to distinguish
missing/optional files from actual gh/API/parsing failures, and re-raise or
propagate the real failures so the caller can return exit 2 instead of falling
through to not_authorized. Keep the existing authorized/aliases merge behavior,
but make sure genuine lookup errors from run_gh, yaml.safe_load, or alias
processing are not silently ignored.
- Around line 126-148: The fallback path in check_authorized.py does not process
nested filters entries, so authorized names under filters are missed when
HAS_YAML is false. Update the non-YAML branch to either fail fast with exit 2 if
PyYAML is unavailable, or extend the fallback parsing logic used by
_parse_simple_yaml_list so it also reads approvers and reviewers inside filters
sections. Keep the behavior consistent with the HAS_YAML branch and verify
authorized.add receives those nested entries too.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5fd2424c-21d2-43b3-832e-e3112783ca51

📥 Commits

Reviewing files that changed from the base of the PR and between 5f26b20 and 4f77060.

📒 Files selected for processing (4)
  • docs/index.html
  • plugins/openshift-developer/.claude-plugin/plugin.json
  • plugins/openshift-developer/skills/address-review-pr/SKILL.md
  • plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py

Comment thread plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py Outdated
@enxebre enxebre changed the title address-review-pr: add author authorization check CNTRLPLANE-3677: address-review-pr: add author authorization check Jun 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 30, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 30, 2026

Copy link
Copy Markdown

@enxebre: This pull request references CNTRLPLANE-3677 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Add check_authorized.py script that verifies PR comment authors against OWNERS, OWNERS_ALIASES, approved bots, and org membership before processing their feedback
  • Update the skill's Step 0.5 to invoke the script deterministically instead of describing authorization logic in prose
  • Prevents untrusted actors from instructing the agent to make changes via review comments

This replicates the authorization logic from the review-agent comment_analyzer.py as a standalone reusable script.

Test plan

  • check_authorized.py openshift hypershift enxebre → authorized (owners), exit 0
  • check_authorized.py openshift hypershift 'coderabbitai[bot]' → authorized (approved_bot), exit 0
  • check_authorized.py openshift hypershift random-attacker-user → not authorized, exit 1
  • check_authorized.py openshift hypershift openshift-ci-robot → ignored bot, exit 1

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
  • Added an authorization check before processing PR review comments, so only approved commenters are considered.
  • Bug Fixes
  • Ignored unauthorized or unverified review comments to reduce noisy or unintended responses.
  • Improved handling of authorization failures by safely skipping affected comments.
  • Chores
  • Updated the plugin release version to 1.1.7.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Only process review comments from authorized users: OWNERS,
OWNERS_ALIASES members, approved bots (coderabbitai), or org
members. Prevents untrusted actors from instructing the agent
to make changes via review comments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@enxebre
enxebre force-pushed the address-review-pr-author-authorization branch from 4f77060 to e223311 Compare June 30, 2026 13:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py`:
- Around line 180-194: The org membership lookup in is_org_member() is treating
transport/auth/timeouts as a normal non-member result, which causes main() to
exit with the wrong status. Update is_org_member() to distinguish a real
404/non-member response from gh API failures and exceptions, returning False
only for an actual non-member and surfacing lookup errors (for example via an
exception or separate failure signal) so main() can follow its error path and
exit 2.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a547ab59-a5ea-49b2-a3f4-7a3f08c4364a

📥 Commits

Reviewing files that changed from the base of the PR and between 4f77060 and e223311.

📒 Files selected for processing (5)
  • docs/index.html
  • plugins/openshift-developer/.claude-plugin/plugin.json
  • plugins/openshift-developer/README.md
  • plugins/openshift-developer/skills/address-review-pr/SKILL.md
  • plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py
✅ Files skipped from review due to trivial changes (3)
  • plugins/openshift-developer/README.md
  • plugins/openshift-developer/.claude-plugin/plugin.json
  • docs/index.html
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/openshift-developer/skills/address-review-pr/SKILL.md

Comment thread plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py Outdated
Distinguish real non-member responses (404) from API/auth/network
failures in is_org_member(). Failures now raise OrgMembershipLookupError
so main() routes them to exit 2 (error path) instead of exit 1
(not authorized).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py (1)

200-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Chain the re-raised exceptions with from e.

Both re-raises inside the except blocks drop the original traceback context, per the Ruff B904 hint.

🔧 Proposed fix
     except subprocess.TimeoutExpired:
-        raise OrgMembershipLookupError(f"Org membership check timed out for {login}")
+        raise OrgMembershipLookupError(f"Org membership check timed out for {login}") from None
     except Exception as e:
-        raise OrgMembershipLookupError(f"Failed to check org membership for {login}: {e}")
+        raise OrgMembershipLookupError(f"Failed to check org membership for {login}: {e}") from e
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py`
around lines 200 - 204, Update the exception handling in the org membership
check logic so the re-raised OrgMembershipLookupError instances preserve the
original exception context. In the try/except block that catches
subprocess.TimeoutExpired and the generic Exception as e, raise the new
OrgMembershipLookupError using exception chaining with from e, and keep the bare
raise only where you are intentionally re-throwing an existing active exception.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py`:
- Around line 200-204: Update the exception handling in the org membership check
logic so the re-raised OrgMembershipLookupError instances preserve the original
exception context. In the try/except block that catches
subprocess.TimeoutExpired and the generic Exception as e, raise the new
OrgMembershipLookupError using exception chaining with from e, and keep the bare
raise only where you are intentionally re-throwing an existing active exception.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 42fdf2a8-6eaf-46e5-b723-f0fe6ac0ab3b

📥 Commits

Reviewing files that changed from the base of the PR and between e223311 and 22497f4.

📒 Files selected for processing (1)
  • plugins/openshift-developer/skills/address-review-pr/scripts/check_authorized.py

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 6, 2026
@openshift-ci

openshift-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, enxebre

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot
openshift-merge-bot Bot merged commit fb6434a into openshift-eng:main Jul 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants