mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
080a96fed4
* Refactor fuzzing utils and add 3 fuzzers Signed-off-by: AdamKorcz <adam@adalogics.com> * Fix lint issues Signed-off-by: AdamKorcz <adam@adalogics.com> * use latest go-jmespath Signed-off-by: AdamKorcz <adam@adalogics.com> * Check layer size (#8552) * fix excessive logs Signed-off-by: Jim Bugwadia <jim@nirmata.com> * check fetched layer size Signed-off-by: Jim Bugwadia <jim@nirmata.com> * check sig layer size Signed-off-by: Jim Bugwadia <jim@nirmata.com> --------- Signed-off-by: Jim Bugwadia <jim@nirmata.com> Signed-off-by: AdamKorcz <adam@adalogics.com> * fix lint issues Signed-off-by: AdamKorcz <adam@adalogics.com> --------- Signed-off-by: AdamKorcz <adam@adalogics.com> Signed-off-by: Jim Bugwadia <jim@nirmata.com> Co-authored-by: Jim Bugwadia <jim@nirmata.com>
32 lines
677 B
Go
32 lines
677 B
Go
package context
|
|
|
|
import (
|
|
"testing"
|
|
|
|
admissionv1 "k8s.io/api/admission/v1"
|
|
|
|
"github.com/kyverno/kyverno/pkg/config"
|
|
"github.com/kyverno/kyverno/pkg/engine/jmespath"
|
|
)
|
|
|
|
var (
|
|
fuzzJp = jmespath.New(config.NewDefaultConfiguration(false))
|
|
)
|
|
|
|
func FuzzHasChanged(f *testing.F) {
|
|
f.Fuzz(func(t *testing.T, obj1, obj2, jString string) {
|
|
ctx := createFuzzContext(obj1, obj2)
|
|
ctx.HasChanged(jString)
|
|
})
|
|
}
|
|
|
|
func createFuzzContext(obj, oldObj string) Interface {
|
|
request := admissionv1.AdmissionRequest{}
|
|
request.Operation = "UPDATE"
|
|
request.Object.Raw = []byte(obj)
|
|
request.OldObject.Raw = []byte(oldObj)
|
|
|
|
ctx := NewContext(fuzzJp)
|
|
ctx.AddRequest(request)
|
|
return ctx
|
|
}
|