1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 18:38:40 +00:00

fix: Overridden request.operation is not considered by match/exclude with operations (#8361)

* fix: verifyImages w/ multiple entries is not consistent

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* clean

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix: Kyverno apply produces false positives when validating 'empty dangling' tags

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix: Overridden request.operation is not considered by match/exclude with operations

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-09-12 20:56:31 +02:00 committed by GitHub
parent 954415a311
commit e3188fca8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -204,8 +204,11 @@ func (p *PolicyProcessor) makePolicyContext(
}
resourceValues = vals
}
if resourceValues["request.operation"] == "DELETE" {
switch resourceValues["request.operation"] {
case "DELETE":
operation = kyvernov1.Delete
case "UPDATE":
operation = kyvernov1.Update
}
policyContext, err := engine.NewPolicyContext(
jp,
@ -217,6 +220,9 @@ func (p *PolicyProcessor) makePolicyContext(
if err != nil {
log.Log.Error(err, "failed to create policy context")
}
if operation == kyvernov1.Update {
policyContext = policyContext.WithOldResource(resource)
}
policyContext = policyContext.
WithPolicy(policy).
WithNamespaceLabels(namespaceLabels).