1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

fix the entry length validation for the verify image rule (#5384)

Signed-off-by: ShutingZhao <shuting@nirmata.com>

Signed-off-by: ShutingZhao <shuting@nirmata.com>
This commit is contained in:
shuting 2022-11-17 19:55:02 +08:00 committed by GitHub
parent 6fe8a4ae07
commit b1367fd497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View file

@ -180,6 +180,28 @@ func Test_ImageVerification(t *testing.T) {
}
},
},
{
name: "multiple entries",
subject: ImageVerification{
ImageReferences: []string{"*"},
Attestors: []AttestorSet{
{
Entries: []Attestor{
{
Keys: &StaticKeyAttestor{
PublicKeys: "key1",
},
},
{
Keys: &StaticKeyAttestor{
PublicKeys: "key2",
},
},
},
},
},
},
},
}
for _, test := range testCases {

View file

@ -256,8 +256,6 @@ func validateAttestorSet(as *AttestorSet, path *field.Path) (errs field.ErrorLis
if len(as.Entries) == 0 {
errs = append(errs, field.Invalid(path, as, "An entry is required"))
} else if len(as.Entries) > 1 {
errs = append(errs, field.Invalid(path, as, "Only one entry is currently supported"))
}
entriesPath := path.Child("entries")

View file

@ -293,13 +293,6 @@ func Validate(policy kyvernov1.PolicyInterface, client dclient.Interface, mock b
}
}
if rule.HasVerifyImages() {
verifyImagePath := rulePath.Child("verifyImages")
for index, i := range rule.VerifyImages {
errs = append(errs, i.Validate(verifyImagePath.Index(index))...)
}
}
if len(errs) != 0 {
return warnings, errs.ToAggregate()
}