1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/engine/api/fuzz_test.go
AdamKorcz 98f57df5ae
feat: add fuzzers from cncf-fuzzing (#8027)
* feat: add fuzzers from cncf-fuzzing

Signed-off-by: AdamKorcz <adam@adalogics.com>

* linter fixes

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

---------

Signed-off-by: AdamKorcz <adam@adalogics.com>
Signed-off-by: ShutingZhao <shuting@nirmata.com>
Co-authored-by: ShutingZhao <shuting@nirmata.com>
2023-08-16 16:42:37 +00:00

33 lines
735 B
Go

package api
import (
"testing"
fuzz "github.com/AdaLogics/go-fuzz-headers"
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
)
func FuzzEngineResponse(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
ff := fuzz.NewConsumer(data)
resource, err := ff.GetBytes()
if err != nil {
return
}
resourceUnstructured, err := kubeutils.BytesToUnstructured(resource)
if err != nil {
return
}
namespaceLabels := make(map[string]string)
ff.FuzzMap(&namespaceLabels)
resp := NewEngineResponse(*resourceUnstructured, nil, namespaceLabels)
_ = resp.GetPatches()
_ = resp.GetFailedRules()
_ = resp.GetFailedRulesWithErrors()
_ = resp.GetValidationFailureAction()
_ = resp.GetSuccessRules()
})
}