Skip to content

OLS-3087: Replace wildcard RBAC verb on namespace-scoped roles/rolebindings#1788

Open
xrajesh wants to merge 2 commits into
openshift:mainfrom
xrajesh:xav/ols-3087-rbac-wildcard
Open

OLS-3087: Replace wildcard RBAC verb on namespace-scoped roles/rolebindings#1788
xrajesh wants to merge 2 commits into
openshift:mainfrom
xrajesh:xav/ols-3087-rbac-wildcard

Conversation

@xrajesh

@xrajesh xrajesh commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces wildcard * verb on the namespace-scoped Role for roles and rolebindings in openshift-lightspeed with explicit verbs: get, list, create, update, delete
  • Removes implicit escalate and bind permissions that the operator never uses (SAR finding OLS-3087)
  • Regenerated RBAC manifests via make manifests; all unit tests pass

Test plan

  • make manifests regenerates config/rbac/role.yaml correctly
  • make test passes — all controller packages green
  • Verify operator reconciles roles/rolebindings successfully on a cluster with the tightened permissions

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Tightened resource permissions for the application’s namespace-managed roles, reducing unnecessary access while keeping normal operations intact.
    • Improved security posture by replacing broad permissions with a more specific set of allowed actions.

…ndings

The namespace-scoped Role in openshift-lightspeed granted verb '*' on
roles and rolebindings, which implicitly includes 'escalate' and 'bind'.
Replace with the explicit verbs the operator actually uses:
get, list, create, update, delete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 3, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 3, 2026

Copy link
Copy Markdown

@xrajesh: This pull request references OLS-3087 which is a valid jira issue.

Details

In response to this:

Summary

  • Replaces wildcard * verb on the namespace-scoped Role for roles and rolebindings in openshift-lightspeed with explicit verbs: get, list, create, update, delete
  • Removes implicit escalate and bind permissions that the operator never uses (SAR finding OLS-3087)
  • Regenerated RBAC manifests via make manifests; all unit tests pass

Test plan

  • make manifests regenerates config/rbac/role.yaml correctly
  • make test passes — all controller packages green
  • Verify operator reconciles roles/rolebindings successfully on a cluster with the tightened permissions

🤖 Generated with Claude Code

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.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This change updates a kubebuilder RBAC annotation in the OLS config controller, narrowing the permitted verbs for roles and rolebindings resources in the openshift-lightspeed namespace from wildcard (*) to an explicit set: get, list, create, update, delete.

Changes

RBAC Annotation Update

Layer / File(s) Summary
Narrow RBAC verbs for roles/rolebindings
internal/controller/olsconfig_controller.go
The kubebuilder RBAC annotation for roles;rolebindings is changed from verbs=* to explicit verbs=get;list;create;update;delete.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: narrowing namespace-scoped Role/RoleBinding RBAC verbs from wildcard to explicit permissions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from blublinsky and bparees July 3, 2026 23:37
@openshift-ci

openshift-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign blublinsky for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@internal/controller/olsconfig_controller.go`:
- Line 132: The RBAC marker for the OlsConfig controller is missing the watch
verb for roles and rolebindings, while listOwnedResources() uses r.List() on
both resources. Update the kubebuilder RBAC annotation in OlsConfig controller
metadata to include watch for roles;rolebindings and avoid adding patch since it
is not used.
🪄 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: 57a1c8d4-fd9a-4bfa-ba25-24a8fcb21cf7

📥 Commits

Reviewing files that changed from the base of the PR and between a1bbf9c and 92728de.

⛔ Files ignored due to path filters (1)
  • config/rbac/role.yaml is excluded by !config/rbac/role.yaml
📒 Files selected for processing (1)
  • internal/controller/olsconfig_controller.go

// +kubebuilder:rbac:groups=operator.openshift.io,resources=consoles,verbs=watch;list;get;update
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings;rolebindings,verbs=get;list;create;update;patch;delete;watch
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,namespace=openshift-lightspeed,resources=roles;rolebindings,verbs=*
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,namespace=openshift-lightspeed,resources=roles;rolebindings,verbs=get;list;create;update;delete

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate reconciler code touching Role/RoleBinding and inspect the client calls used.
rg -nP --type=go -C3 '\b(rbacv1\.(Role|RoleBinding)|Role\{|RoleBinding\{)' internal/controller | head -100
rg -nP --type=go -C2 '\.(Patch|Update)\(ctx' internal/controller | rg -B5 -A2 'Role'

Repository: openshift/lightspeed-operator

Length of output: 8072


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- Role/RoleBinding client usage in internal/controller ---'
rg -n --type=go '\b(rbacv1\.(Role|RoleBinding)|RoleList|RoleBindingList)\b|controllerutil\.(CreateOrPatch|CreateOrUpdate)|\.(Get|List|Create|Update|Patch|Delete)\(' internal/controller/olsconfig_controller.go internal/controller -g'*.go' | sed -n '1,220p'

echo
echo '--- SetupWithManager and cache/client options around OLSConfig controller ---'
sed -n '1,220p' internal/controller/olsconfig_controller.go

Repository: openshift/lightspeed-operator

Length of output: 40647


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- SetupWithManager / watches / owns in internal/controller/olsconfig_controller.go ---'
rg -n --type=go '\bSetupWithManager\b|Owns\(|Watches\(' internal/controller/olsconfig_controller.go
sed -n '820,980p' internal/controller/olsconfig_controller.go

Repository: openshift/lightspeed-operator

Length of output: 6883


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- SetupWithManager / watches / owns in internal/controller/olsconfig_controller.go ---'
rg -n --type=go '\bSetupWithManager\b|Owns\(|Watches\(' internal/controller/olsconfig_controller.go
echo
sed -n '820,980p' internal/controller/olsconfig_controller.go

Repository: openshift/lightspeed-operator

Length of output: 6884


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- Role/RoleBinding listOwnedResources usage ---'
rg -n --type=go 'listOwnedResources\(' internal/controller/olsconfig_controller.go internal/controller -g'*.go'

echo
echo '--- appserver role/rolebinding reconciliation calls ---'
sed -n '250,310p' internal/controller/appserver/reconciler.go

Repository: openshift/lightspeed-operator

Length of output: 3397


Add watch to the roles;rolebindings RBAC marker listOwnedResources() calls r.List() on both types, so the marker needs watch; patch isn’t used here.

🤖 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 `@internal/controller/olsconfig_controller.go` at line 132, The RBAC marker for
the OlsConfig controller is missing the watch verb for roles and rolebindings,
while listOwnedResources() uses r.List() on both resources. Update the
kubebuilder RBAC annotation in OlsConfig controller metadata to include watch
for roles;rolebindings and avoid adding patch since it is not used.

The initial wildcard-to-explicit verb replacement omitted watch and patch,
which are required by controller-runtime informers and CreateOrUpdate.
Without them the operator cannot reconcile OLSConfig into a working
deployment, causing all e2e tests to cascade-fail.

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

openshift-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown

@xrajesh: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/bundle-e2e-4-21 9dcbe6b link true /test bundle-e2e-4-21

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants