Repository navigation
fix(kubescape): enable riskAcceptance so SecurityException CRs are applied - #2298
Merged
Merged
Conversation
…plied The platform deploys 9 ClusterSecurityException CRs in k8s/bases/infrastructure/security-exceptions/, but the dashboard shows "excluding 0 resources and 0 controls" — they have never taken effect. Root cause: the kubescape-operator chart gates the RBAC that lets the operator/kubevuln/scanner read securityexceptions + clustersecurityexceptions behind `capabilities.riskAcceptance` (chart default: `disable`). The platform never set it, so no component has permission to read the CRs; the scanner logs "Loaded exceptions" but loads an empty set. Confirmed against the live cluster: no ClusterRole grants securityexception access. Enabling it: - creates the securityexception RBAC (operator/kubevuln/scanner clusterroles), and - activates the CRD exception getter, which resolves the CRs' spec.match.namespaceSelector.matchExpressions against live namespaces (verified in kubescape core/cautils/getter/crdexceptionsgetter.go — the "matchExpressions not applied" caveat there is only for objectSelector, not namespaceSelector, which the platform's CRs use). NOTE / follow-up: this makes the existing exception set live, which will suppress the findings those 9 CRs cover (privileged infra, controller RBAC, SA tokens). Per the no-exemptions direction, those exceptions will be trimmed to only the genuinely-irreducible as real fixes land (e.g. Velero -> CSI snapshots removes the velero node-agent exception). Exemptions are a last resort behind real fixes; this PR only repairs the mechanism so a minimal, reviewed exception set can actually function. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 1.80.9 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
4 tasks
Contributor
Author
Correction to the PR description: the |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The platform deploys 9
ClusterSecurityExceptionCRs (k8s/bases/infrastructure/security-exceptions/), but the in-cluster dashboard shows "excluding 0 resources and 0 controls" — they have never taken effect. The repo's own docs assumed these "feed the in-cluster operator"; in reality they're orphaned.Root cause (traced against the live cluster + chart source)
The kubescape-operator chart gates the RBAC that lets the operator/kubevuln/scanner read
securityexceptions+clustersecurityexceptionsbehindcapabilities.riskAcceptance(chart defaultdisable):The platform never set it, so no ClusterRole grants securityexception access (verified live:
kubescape/operator/kubevulnclusterroles have none). The scanner logsLoading exceptions… Loaded exceptionsbut loads an empty set.Fix
capabilities.riskAcceptance: enable. This:spec.match.namespaceSelector.matchExpressionsagainst live namespaces. (Verified inkubescape/core/cautils/getter/crdexceptionsgetter.go— the "matchExpressions not applied" caveat there is only forobjectSelector;namespaceSelector— which the platform's CRs use — is resolved via the k8s client.)Important follow-up (no-exemptions direction)
Repairing the mechanism makes the existing 9 exceptions live, which will suppress the findings they cover (privileged infra, controller RBAC, SA tokens). Per the directive to prefer real fixes, those exceptions will be trimmed to only the genuinely-irreducible as real fixes land — e.g. Velero → CSI snapshots removes the velero node-agent exception. Exemptions stay a last resort behind real fixes; this PR only makes a minimal, reviewed exception set able to function.
🤖 Generated with Claude Code