Repository navigation
feat: support spec.background on CEL PolicyException - #129
Open
anushkagupta200615-jpg wants to merge 1 commit into
Open
anushkagupta200615-jpg wants to merge 1 commit into
anushkagupta200615-jpg wants to merge 1 commit into
Conversation
Support configuring spec.background on CEL PolicyExceptions to allow disabling exceptions during background scans, matching legacy kyverno.io/v2 PolicyExceptions. Refs: kyverno/kyverno#17847 Signed-off-by: anushkagupta200615-jpg <anushkagupta200615@gmail.com>
3 of 8 tasks
This branch has not been deployed
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.
Explanation
This PR adds support for
.spec.backgroundon CEL-basedPolicyExceptionresources (policies.kyverno.io), bringing parity with legacykyverno.io/v2PolicyExceptions.Currently, CEL PolicyExceptions apply unconditionally to both admission reviews and background report scans. In enterprise environments, security and compliance teams often grant exceptions to allow resource deployments at admission time without blocking developers, while requiring non compliant resources to continue being reported as violations during background scans (
PolicyReports) for audit tracking. Adding.spec.background: falseallows users to disable applying exceptions during background scans while preserving admission bypass behavior.Related issue
Part of kyverno/kyverno#17847 (API changes)
Discussed with @JimBugwadia on the
#kyvernoKubernetes Slack channel.Proposed Changes
Background *bool(json:"background,omitempty") toPolicyExceptionSpecinapi/policies.kyverno.io/v1alpha1(and exposed viav1beta1).BackgroundProcessingEnabled() boolwhich returnstrueifBackgroundisnilortrue. Existing exceptions without this field maintain identical behavior.zz_generated.deepcopy.go).config/crds/policies.kyverno.io_policyexceptions.yaml,config/crds.yaml, and Helm chart templates incharts/kyverno-api/templates/crds/.BackgroundProcessingEnabled()inapi/policies.kyverno.io/v1beta1/policy_exception_test.gocoveringnil,true, andfalsevalues.Checklist
Further Comments
This is Part 1 of the implementation for kyverno/kyverno#17847:
kyverno/api): Defines the API field, helpers, and regenerated CRDs.kyverno/kyverno): UpdatesFetchCELPolicyExceptionsinpkg/controllers/report/utils/utils.goto filter out exceptions whereBackgroundProcessingEnabled() == false.