Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/openshift/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resources:
- ../default
- cluster-monitoring-view-binding.yaml
- metrics-reader-token.yaml
- prometheus-metrics-auth-binding.yaml
- prometheus-metrics-reader-binding.yaml

patches:
- path: configmap-patch.yaml
Expand Down
14 changes: 0 additions & 14 deletions config/openshift/prometheus-metrics-auth-binding.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions config/openshift/prometheus-metrics-reader-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Grant GET /metrics permission to the controller-manager SA whose token is
# used by Prometheus (via authorization.credentials) to scrape the WVA
# metrics endpoint. The WVA metrics endpoint performs a SubjectAccessReview
# checking this permission.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: workload-variant-autoscaler-ocp-prometheus-metrics-reader
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: metrics-reader
subjects:
- kind: ServiceAccount
name: controller-manager
Comment on lines +13 to +15
Copy link
Copy Markdown

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:

#!/bin/bash
# Verify the binding subject explicitly sets namespace and matches overlay namespace.
set -euo pipefail

echo "Checking ServiceAccount subject block:"
awk 'BEGIN{p=0} /subjects:/{p=1} p{print} /namespace:/{if(p){exit}}' config/openshift/prometheus-metrics-reader-binding.yaml

echo
echo "Checking overlay namespace:"
rg -n '^\s*namespace:\s*' config/openshift/kustomization.yaml

Repository: opendatahub-io/workload-variant-autoscaler

Length of output: 262


Add namespace to ServiceAccount subject — binding targets wrong namespace (CWE-863: Improper Authorization).

Lines 14–15 define a ServiceAccount subject without namespace. Kubernetes defaults this to the "default" namespace, but the overlay (kustomization.yaml line 32) places the controller-manager ServiceAccount in workload-variant-autoscaler-system. This mismatch prevents the binding from authorizing the intended ServiceAccount, breaking metrics access.

Fix
 subjects:
 - kind: ServiceAccount
   name: controller-manager
+  namespace: workload-variant-autoscaler-system
📝 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
subjects:
- kind: ServiceAccount
name: controller-manager
subjects:
- kind: ServiceAccount
name: controller-manager
namespace: workload-variant-autoscaler-system
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/openshift/prometheus-metrics-reader-binding.yaml` around lines 13 -
15, The RoleBinding subject for the ServiceAccount named "controller-manager" is
missing the namespace, causing the binding to target the default namespace;
update the subjects block (the ServiceAccount subject) to include namespace:
workload-variant-autoscaler-system so the RoleBinding correctly authorizes the
controller-manager ServiceAccount in the overlay namespace.

Loading