mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
fix: no skip result when no image match the rule (#6733)
* fix: no skip result when no image match the rule Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix test 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:
parent
c1973b2d1d
commit
94f0829a37
2 changed files with 3 additions and 13 deletions
|
@ -77,7 +77,7 @@ func (e *engine) doVerifyAndPatch(
|
|||
|
||||
logger.V(3).Info("processing image verification rule")
|
||||
|
||||
ruleImages, imageRefs, err := engineutils.ExtractMatchingImages(
|
||||
ruleImages, _, err := engineutils.ExtractMatchingImages(
|
||||
policyContext.NewResource(),
|
||||
policyContext.JSONContext(),
|
||||
rule,
|
||||
|
@ -92,15 +92,6 @@ func (e *engine) doVerifyAndPatch(
|
|||
return
|
||||
}
|
||||
if len(ruleImages) == 0 {
|
||||
internal.AddRuleResponse(
|
||||
resp,
|
||||
internal.RuleSkip(
|
||||
rule,
|
||||
engineapi.ImageVerify,
|
||||
fmt.Sprintf("skip run verification as image in resource not found in imageRefs '%s'", imageRefs),
|
||||
),
|
||||
startTime,
|
||||
)
|
||||
return
|
||||
}
|
||||
policyContext.JSONContext().Restore()
|
||||
|
|
|
@ -446,12 +446,11 @@ var (
|
|||
testOtherKey = `-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEpNlOGZ323zMlhs4bcKSpAKQvbcWi5ZLRmijm6SqXDy0Fp0z0Eal+BekFnLzs8rUXUaXlhZ3hNudlgFJH+nFNMw==\n-----END PUBLIC KEY-----\n`
|
||||
)
|
||||
|
||||
func Test_ConfigMapMissingSuccess(t *testing.T) {
|
||||
func Test_NoMatch(t *testing.T) {
|
||||
policyContext := buildContext(t, testConfigMapMissing, testConfigMapMissingResource, "")
|
||||
cosign.ClearMock()
|
||||
err, _ := testVerifyAndPatchImages(context.TODO(), registryclient.NewOrDie(), nil, policyContext, cfg)
|
||||
assert.Equal(t, len(err.PolicyResponse.Rules), 1)
|
||||
assert.Equal(t, err.PolicyResponse.Rules[0].Status, engineapi.RuleStatusSkip, err.PolicyResponse.Rules[0].Message)
|
||||
assert.Equal(t, len(err.PolicyResponse.Rules), 0)
|
||||
}
|
||||
|
||||
func Test_ConfigMapMissingFailure(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue