diff --git a/LICENSES/vendor/github.com/google/gofuzz/LICENSE b/LICENSES/vendor/sigs.k8s.io/randfill/LICENSE similarity index 98% rename from LICENSES/vendor/github.com/google/gofuzz/LICENSE rename to LICENSES/vendor/sigs.k8s.io/randfill/LICENSE index 119dbf0451a..7c4e4cf8e9e 100644 --- a/LICENSES/vendor/github.com/google/gofuzz/LICENSE +++ b/LICENSES/vendor/sigs.k8s.io/randfill/LICENSE @@ -1,5 +1,4 @@ -= vendor/github.com/google/gofuzz licensed under: = - += vendor/sigs.k8s.io/randfill licensed under: = Apache License Version 2.0, January 2004 @@ -181,7 +180,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" + boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -189,7 +188,8 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2014 The gofuzz Authors + Copyright 2025 The Kubernetes Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -203,4 +203,4 @@ See the License for the specific language governing permissions and limitations under the License. -= vendor/github.com/google/gofuzz/LICENSE 3b83ef96387f14655fc854ddc3c6bd57 += vendor/sigs.k8s.io/randfill/LICENSE 8f245a894b7d4f5880176fafd88faad8 diff --git a/cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go b/cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go index b7ae154bbdd..0bfada0e643 100644 --- a/cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go +++ b/cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -46,8 +46,8 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { } } -func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) @@ -71,16 +71,16 @@ func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c fuzz.Continue) { kubeadm.SetDefaultTimeouts(&obj.Timeouts) } -func fuzzNodeRegistration(obj *kubeadm.NodeRegistrationOptions, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzNodeRegistration(obj *kubeadm.NodeRegistrationOptions, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.IgnorePreflightErrors = nil obj.ImagePullSerial = ptr.To(true) } -func fuzzClusterConfiguration(obj *kubeadm.ClusterConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzClusterConfiguration(obj *kubeadm.ClusterConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.CertificatesDir = "foo" @@ -100,33 +100,33 @@ func fuzzClusterConfiguration(obj *kubeadm.ClusterConfiguration, c fuzz.Continue obj.CACertificateValidityPeriod = &metav1.Duration{Duration: constants.CACertificateValidityPeriod} } -func fuzzDNS(obj *kubeadm.DNS, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzDNS(obj *kubeadm.DNS, c randfill.Continue) { + c.FillNoCustom(obj) obj.Disabled = false } -func fuzzComponentConfigMap(obj *kubeadm.ComponentConfigMap, c fuzz.Continue) { +func fuzzComponentConfigMap(obj *kubeadm.ComponentConfigMap, c randfill.Continue) { // This is intentionally empty because component config does not exists in the public api // (empty mean all ComponentConfigs fields nil, and this is necessary for getting roundtrip passing) } -func fuzzLocalEtcd(obj *kubeadm.LocalEtcd, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzLocalEtcd(obj *kubeadm.LocalEtcd, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.DataDir = "foo" } -func fuzzNetworking(obj *kubeadm.Networking, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzNetworking(obj *kubeadm.Networking, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.DNSDomain = "foo" obj.ServiceSubnet = "bar" } -func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.CACertPath = "foo" @@ -143,20 +143,20 @@ func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c fuzz.Continue) { kubeadm.SetDefaultTimeouts(&obj.Timeouts) } -func fuzzJoinControlPlane(obj *kubeadm.JoinControlPlane, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzJoinControlPlane(obj *kubeadm.JoinControlPlane, c randfill.Continue) { + c.FillNoCustom(obj) } -func fuzzResetConfiguration(obj *kubeadm.ResetConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzResetConfiguration(obj *kubeadm.ResetConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.CertificatesDir = "/tmp" kubeadm.SetDefaultTimeouts(&obj.Timeouts) } -func fuzzUpgradeConfiguration(obj *kubeadm.UpgradeConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzUpgradeConfiguration(obj *kubeadm.UpgradeConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // Pinning values for fields that get defaults if fuzz value is empty string or nil (thus making the round trip test fail) obj.Node.EtcdUpgrade = ptr.To(true) diff --git a/cmd/kubeadm/app/apis/output/fuzzer/fuzzer.go b/cmd/kubeadm/app/apis/output/fuzzer/fuzzer.go index bc02a9a6af3..f48f32df7c6 100644 --- a/cmd/kubeadm/app/apis/output/fuzzer/fuzzer.go +++ b/cmd/kubeadm/app/apis/output/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" @@ -36,8 +36,8 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { } } -func fuzzBootstrapToken(obj *output.BootstrapToken, c fuzz.Continue) { - c.FuzzNoCustom(obj) +func fuzzBootstrapToken(obj *output.BootstrapToken, c randfill.Continue) { + c.FillNoCustom(obj) obj.Token = &bootstraptokenv1.BootstrapTokenString{ID: "uvxdac", Secret: "fq35fuyue3kd4gda"} obj.Description = "" diff --git a/go.mod b/go.mod index 58c1cc11d33..f2c43619d74 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,6 @@ require ( github.com/google/cel-go v0.23.2 github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.6.0 github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 github.com/libopenstorage/openstorage v1.0.0 @@ -107,7 +106,7 @@ require ( k8s.io/kms v0.0.0 k8s.io/kube-aggregator v0.0.0 k8s.io/kube-controller-manager v0.0.0 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/kube-proxy v0.0.0 k8s.io/kube-scheduler v0.0.0 k8s.io/kubectl v0.0.0 @@ -119,7 +118,8 @@ require ( k8s.io/system-validators v1.9.1 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/knftables v0.0.17 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index 779f1f8e8bb..c40b00221a3 100644 --- a/go.sum +++ b/go.sum @@ -293,8 +293,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -658,8 +656,8 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/system-validators v1.9.1 h1:O8xrr08foamG+1uQjAdiTLt/fT+QQJ4QNREfCWvuOws= k8s.io/system-validators v1.9.1/go.mod h1:d4UVrxKu52s0BHU984Peb9VpIq4V9sd8xjTBV/waY/I= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= @@ -677,7 +675,10 @@ sigs.k8s.io/kustomize/kustomize/v5 v5.6.0 h1:MWtRRDWCwQEeW2rnJTqJMuV6Agy56P53Skb sigs.k8s.io/kustomize/kustomize/v5 v5.6.0/go.mod h1:XuuZiQF7WdcvZzEYyNww9A0p3LazCKeJmCjeycN8e1I= sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA= sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/go.work.sum b/go.work.sum index 0653f63650d..f64b55f6550 100644 --- a/go.work.sum +++ b/go.work.sum @@ -148,6 +148,7 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= diff --git a/hack/unwanted-dependencies.json b/hack/unwanted-dependencies.json index b0d6068dc6d..b31e33da672 100644 --- a/hack/unwanted-dependencies.json +++ b/hack/unwanted-dependencies.json @@ -27,7 +27,7 @@ "github.com/golang/mock": "unmaintained, archive mode", "github.com/golang/protobuf": "replace with google.golang.org/protobuf", "github.com/golang/groupcache": "unmaintained", - "github.com/google/gofuzz": "unmaintained, archive mode", + "github.com/google/gofuzz": "unmaintained, use sigs.k8s.io/randfill", "github.com/google/s2a-go": "cloud dependency, unstable", "github.com/google/shlex": "unmaintained, archive mode", "github.com/googleapis/enterprise-certificate-proxy": "references cloud dependencies", @@ -183,17 +183,7 @@ "sigs.k8s.io/apiserver-network-proxy/konnectivity-client" ], "github.com/google/gofuzz": [ - "github.com/json-iterator/go", - "k8s.io/apiextensions-apiserver", - "k8s.io/apimachinery", - "k8s.io/apiserver", - "k8s.io/client-go", - "k8s.io/code-generator", - "k8s.io/kube-aggregator", - "k8s.io/kube-openapi", - "k8s.io/kubernetes", - "k8s.io/sample-apiserver", - "sigs.k8s.io/structured-merge-diff/v4" + "github.com/json-iterator/go" ], "github.com/google/shlex": [ "sigs.k8s.io/kustomize/api", @@ -284,7 +274,6 @@ "github.com/davecgh/go-spew", "github.com/gogo/protobuf", "github.com/golang/protobuf", - "github.com/google/gofuzz", "github.com/google/shlex", "github.com/gregjones/httpcache", "github.com/grpc-ecosystem/go-grpc-prometheus", diff --git a/pkg/api/testing/applyconfiguration_test.go b/pkg/api/testing/applyconfiguration_test.go index 5975456738c..460b5984c6c 100644 --- a/pkg/api/testing/applyconfiguration_test.go +++ b/pkg/api/testing/applyconfiguration_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" apiequality "k8s.io/apimachinery/pkg/api/equality" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -31,6 +30,7 @@ import ( "k8s.io/apimachinery/pkg/util/json" "k8s.io/client-go/applyconfigurations" v1mf "k8s.io/client-go/applyconfigurations/core/v1" + "sigs.k8s.io/randfill" "k8s.io/kubernetes/pkg/api/legacyscheme" api "k8s.io/kubernetes/pkg/apis/core" @@ -166,22 +166,22 @@ func fuzzObject(t *testing.T, gvk schema.GroupVersionKind) runtime.Object { // Ensure that InitContainers and their statuses are not generated. This // is because in this test we are simply doing json operations, in which // those disappear. - func(s *api.PodSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *api.PodSpec, c randfill.Continue) { + c.FillNoCustom(s) s.InitContainers = nil }, - func(s *api.PodStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *api.PodStatus, c randfill.Continue) { + c.FillNoCustom(s) s.InitContainerStatuses = nil }, // Apply configuration types do not have managed fields, so we exclude // them in our fuzz test cases. - func(s *v1.ObjectMeta, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *v1.ObjectMeta, c randfill.Continue) { + c.FillNoCustom(s) s.ManagedFields = nil s.SelfLink = "" }, - ).Fuzz(internalObj) + ).Fill(internalObj) item, err := legacyscheme.Scheme.New(externalVersion.WithKind(kind)) if err != nil { diff --git a/pkg/api/testing/conversion_test.go b/pkg/api/testing/conversion_test.go index 02ea015d37e..d4d814a8e63 100644 --- a/pkg/api/testing/conversion_test.go +++ b/pkg/api/testing/conversion_test.go @@ -36,7 +36,7 @@ func BenchmarkPodConversion(b *testing.B) { apiObjectFuzzer := fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(benchmarkSeed), legacyscheme.Codecs) items := make([]api.Pod, 4) for i := range items { - apiObjectFuzzer.Fuzz(&items[i]) + apiObjectFuzzer.Fill(&items[i]) items[i].Spec.InitContainers = nil items[i].Status.InitContainerStatuses = nil } diff --git a/pkg/api/testing/copy_test.go b/pkg/api/testing/copy_test.go index 8f3acbda0e9..8e8a5894c9a 100644 --- a/pkg/api/testing/copy_test.go +++ b/pkg/api/testing/copy_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" @@ -43,12 +43,12 @@ func TestDeepCopyApiObjects(t *testing.T) { } } -func doDeepCopyTest(t *testing.T, kind schema.GroupVersionKind, f *fuzz.Fuzzer) { +func doDeepCopyTest(t *testing.T, kind schema.GroupVersionKind, f *randfill.Filler) { item, err := legacyscheme.Scheme.New(kind) if err != nil { t.Fatalf("Could not create a %v: %s", kind, err) } - f.Fuzz(item) + f.Fill(item) itemCopy := item.DeepCopyObject() if !reflect.DeepEqual(item, itemCopy) { t.Errorf("\nexpected: %#v\n\ngot: %#v\n\ndiff: %v", item, itemCopy, cmp.Diff(item, itemCopy)) @@ -61,7 +61,7 @@ func doDeepCopyTest(t *testing.T, kind schema.GroupVersionKind, f *fuzz.Fuzzer) } // Refuzz the copy, which should have no effect on the original - f.Fuzz(itemCopy) + f.Fill(itemCopy) postfuzzData := &bytes.Buffer{} if err := legacyscheme.Codecs.LegacyCodec(kind.GroupVersion()).Encode(item, postfuzzData); err != nil { diff --git a/pkg/api/testing/defaulting_test.go b/pkg/api/testing/defaulting_test.go index 06b59825d0b..3dab45f7119 100644 --- a/pkg/api/testing/defaulting_test.go +++ b/pkg/api/testing/defaulting_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" apiv1 "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" @@ -219,20 +219,20 @@ func TestDefaulting(t *testing.T) { t.Run(gvk.String(), func(t *testing.T) { // Each sub-tests gets its own fuzzer instance to make running it independent // from what other tests ran before. - f := fuzz.New().NilChance(.5).NumElements(1, 1).RandSource(rand.NewSource(1)) + f := randfill.New().NilChance(.5).NumElements(1, 1).RandSource(rand.NewSource(1)) f.Funcs( - func(s *runtime.RawExtension, c fuzz.Continue) {}, - func(s *metav1.LabelSelector, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *runtime.RawExtension, c randfill.Continue) {}, + func(s *metav1.LabelSelector, c randfill.Continue) { + c.FillNoCustom(s) s.MatchExpressions = nil // need to fuzz this specially }, - func(s *metav1.ListOptions, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *metav1.ListOptions, c randfill.Continue) { + c.FillNoCustom(s) s.LabelSelector = "" // need to fuzz requirement strings specially s.FieldSelector = "" // need to fuzz requirement strings specially }, - func(s *extensionsv1beta1.ScaleStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *extensionsv1beta1.ScaleStatus, c randfill.Continue) { + c.FillNoCustom(s) s.TargetSelector = "" // need to fuzz requirement strings specially }, ) @@ -262,7 +262,7 @@ func TestDefaulting(t *testing.T) { if err != nil { t.Fatal(err) } - f.Fuzz(src) + f.Fill(src) src.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) @@ -289,10 +289,10 @@ func TestDefaulting(t *testing.T) { } func BenchmarkPodDefaulting(b *testing.B) { - f := fuzz.New().NilChance(.5).NumElements(1, 1).RandSource(rand.NewSource(1)) + f := randfill.New().NilChance(.5).NumElements(1, 1).RandSource(rand.NewSource(1)) items := make([]apiv1.Pod, 100) for i := range items { - f.Fuzz(&items[i]) + f.Fill(&items[i]) } scheme := legacyscheme.Scheme diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index e2773c78c2e..a38fb8567b9 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -19,7 +19,7 @@ package testing import ( "fmt" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" @@ -51,9 +51,9 @@ import ( // values in a Kubernetes context. func overrideGenericFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(j *runtime.Object, c fuzz.Continue) { + func(j *runtime.Object, c randfill.Continue) { // TODO: uncomment when round trip starts from a versioned object - if true { //c.RandBool() { + if true { // c.Bool() { *j = &runtime.Unknown{ // We do not set TypeMeta here because it is not carried through a round trip Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`), @@ -62,15 +62,15 @@ func overrideGenericFuncs(codecs runtimeserializer.CodecFactory) []interface{} { } else { types := []runtime.Object{&api.Pod{}, &api.ReplicationController{}} t := types[c.Rand.Intn(len(types))] - c.Fuzz(t) + c.Fill(t) *j = t } }, - func(r *runtime.RawExtension, c fuzz.Continue) { + func(r *runtime.RawExtension, c randfill.Continue) { // Pick an arbitrary type and fuzz it types := []runtime.Object{&api.Pod{}, &apps.Deployment{}, &api.Service{}} obj := types[c.Rand.Intn(len(types))] - c.Fuzz(obj) + c.Fill(obj) var codec runtime.Codec switch obj.(type) { diff --git a/pkg/api/testing/serialization_proto_test.go b/pkg/api/testing/serialization_proto_test.go index f189b7608f3..6ba4a47e740 100644 --- a/pkg/api/testing/serialization_proto_test.go +++ b/pkg/api/testing/serialization_proto_test.go @@ -99,7 +99,7 @@ func fieldsHaveProtobufTags(obj reflect.Type) error { func TestProtobufRoundTrip(t *testing.T) { obj := &v1.Pod{} - fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(benchmarkSeed), legacyscheme.Codecs).Fuzz(obj) + fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(benchmarkSeed), legacyscheme.Codecs).Fill(obj) // InitContainers are turned into annotations by conversion. obj.Spec.InitContainers = nil obj.Status.InitContainerStatuses = nil diff --git a/pkg/api/testing/serialization_test.go b/pkg/api/testing/serialization_test.go index 01bba999b3f..2a8f94f0512 100644 --- a/pkg/api/testing/serialization_test.go +++ b/pkg/api/testing/serialization_test.go @@ -51,7 +51,7 @@ import ( // fuzzInternalObject fuzzes an arbitrary runtime object using the appropriate // fuzzer registered with the apitesting package. func fuzzInternalObject(t *testing.T, forVersion schema.GroupVersion, item runtime.Object, seed int64) runtime.Object { - fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(seed), legacyscheme.Codecs).Fuzz(item) + fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(seed), legacyscheme.Codecs).Fill(item) j, err := meta.TypeAccessor(item) if err != nil { @@ -331,7 +331,7 @@ func TestUnversionedTypes(t *testing.T) { func TestObjectWatchFraming(t *testing.T) { f := fuzzer.FuzzerFor(FuzzerFuncs, rand.NewSource(benchmarkSeed), legacyscheme.Codecs) secret := &api.Secret{} - f.Fuzz(secret) + f.Fill(secret) if secret.Data == nil { secret.Data = map[string][]byte{} } @@ -418,7 +418,7 @@ func benchmarkItems(b *testing.B) []v1.Pod { items := make([]v1.Pod, 10) for i := range items { var pod api.Pod - apiObjectFuzzer.Fuzz(&pod) + apiObjectFuzzer.Fill(&pod) pod.Spec.InitContainers, pod.Status.InitContainerStatuses = nil, nil out, err := legacyscheme.Scheme.ConvertToVersion(&pod, v1.SchemeGroupVersion) if err != nil { @@ -434,7 +434,7 @@ func benchmarkItemsList(b *testing.B, numItems int) v1.PodList { items := make([]v1.Pod, numItems) for i := range items { var pod api.Pod - apiObjectFuzzer.Fuzz(&pod) + apiObjectFuzzer.Fill(&pod) pod.Spec.InitContainers, pod.Status.InitContainerStatuses = nil, nil out, err := legacyscheme.Scheme.ConvertToVersion(&pod, v1.SchemeGroupVersion) if err != nil { diff --git a/pkg/api/testing/unstructured_test.go b/pkg/api/testing/unstructured_test.go index 03539b048f4..47eaeddeb00 100644 --- a/pkg/api/testing/unstructured_test.go +++ b/pkg/api/testing/unstructured_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" @@ -54,15 +54,15 @@ func doRoundTrip(t *testing.T, internalVersion schema.GroupVersion, externalVers // because in this test we are simply doing json operations, in which // those disappear. Funcs( - func(s *api.PodSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *api.PodSpec, c randfill.Continue) { + c.FillNoCustom(s) s.InitContainers = nil }, - func(s *api.PodStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *api.PodStatus, c randfill.Continue) { + c.FillNoCustom(s) s.InitContainerStatuses = nil }, - ).Fuzz(internalObj) + ).Fill(internalObj) item, err := legacyscheme.Scheme.New(externalVersion.WithKind(kind)) if err != nil { diff --git a/pkg/apis/admission/fuzzer/fuzzer.go b/pkg/apis/admission/fuzzer/fuzzer.go index 73908f667ba..83228eaf982 100644 --- a/pkg/apis/admission/fuzzer/fuzzer.go +++ b/pkg/apis/admission/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -27,7 +27,7 @@ import ( // Funcs returns the fuzzer functions for the admission api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *runtime.RawExtension, c fuzz.Continue) { + func(s *runtime.RawExtension, c randfill.Continue) { u := &unstructured.Unstructured{Object: map[string]interface{}{ "apiVersion": "unknown.group/unknown", "kind": "Something", diff --git a/pkg/apis/admissionregistration/fuzzer/fuzzer.go b/pkg/apis/admissionregistration/fuzzer/fuzzer.go index 45fddb02ecf..38474060b6b 100644 --- a/pkg/apis/admissionregistration/fuzzer/fuzzer.go +++ b/pkg/apis/admissionregistration/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" @@ -27,15 +27,15 @@ import ( // Funcs returns the fuzzer functions for the admissionregistration api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *admissionregistration.Rule, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.Rule, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.Scope == nil { s := admissionregistration.AllScopes obj.Scope = &s } }, - func(obj *admissionregistration.ValidatingWebhook, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.ValidatingWebhook, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.FailurePolicy == nil { p := admissionregistration.FailurePolicyType("Fail") obj.FailurePolicy = &p @@ -54,8 +54,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } obj.AdmissionReviewVersions = []string{"v1beta1"} }, - func(obj *admissionregistration.MutatingWebhook, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.MutatingWebhook, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.FailurePolicy == nil { p := admissionregistration.FailurePolicyType("Fail") obj.FailurePolicy = &p @@ -78,28 +78,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } obj.AdmissionReviewVersions = []string{"v1beta1"} }, - func(obj *admissionregistration.ValidatingAdmissionPolicySpec, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.ValidatingAdmissionPolicySpec, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.FailurePolicy == nil { p := admissionregistration.FailurePolicyType("Fail") obj.FailurePolicy = &p } }, - func(obj *admissionregistration.ValidatingAdmissionPolicyBindingSpec, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.ValidatingAdmissionPolicyBindingSpec, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.ValidationActions == nil { obj.ValidationActions = []admissionregistration.ValidationAction{admissionregistration.Deny} } }, - func(obj *admissionregistration.MatchResources, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.MatchResources, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.MatchPolicy == nil { m := admissionregistration.MatchPolicyType("Exact") obj.MatchPolicy = &m } }, - func(obj *admissionregistration.ParamRef, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.ParamRef, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again // Populate required field if obj.ParameterNotFoundAction == nil { @@ -107,26 +107,26 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { obj.ParameterNotFoundAction = &v } }, - func(obj *admissionregistration.MutatingAdmissionPolicySpec, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.MutatingAdmissionPolicySpec, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.FailurePolicy == nil { p := admissionregistration.FailurePolicyType("Fail") obj.FailurePolicy = &p } obj.ReinvocationPolicy = admissionregistration.NeverReinvocationPolicy }, - func(obj *admissionregistration.Mutation, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *admissionregistration.Mutation, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again patchTypes := []admissionregistration.PatchType{admissionregistration.PatchTypeJSONPatch, admissionregistration.PatchTypeApplyConfiguration} obj.PatchType = patchTypes[c.Rand.Intn(len(patchTypes))] if obj.PatchType == admissionregistration.PatchTypeJSONPatch { obj.JSONPatch = &admissionregistration.JSONPatch{} - c.Fuzz(&obj.JSONPatch) + c.Fill(&obj.JSONPatch) obj.ApplyConfiguration = nil } if obj.PatchType == admissionregistration.PatchTypeApplyConfiguration { obj.ApplyConfiguration = &admissionregistration.ApplyConfiguration{} - c.Fuzz(obj.ApplyConfiguration) + c.Fill(obj.ApplyConfiguration) obj.JSONPatch = nil } }, diff --git a/pkg/apis/apps/fuzzer/fuzzer.go b/pkg/apis/apps/fuzzer/fuzzer.go index 2d9ce888eef..1e5aa0a344b 100644 --- a/pkg/apis/apps/fuzzer/fuzzer.go +++ b/pkg/apis/apps/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "fmt" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -31,13 +31,13 @@ import ( // Funcs returns the fuzzer functions for the apps api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(r *apps.ControllerRevision, c fuzz.Continue) { - c.FuzzNoCustom(r) + func(r *apps.ControllerRevision, c randfill.Continue) { + c.FillNoCustom(r) // match the fuzzer default content for runtime.Object r.Data = runtime.RawExtension{Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`)} }, - func(s *apps.StatefulSet, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *apps.StatefulSet, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again // match defaulter if len(s.Spec.PodManagementPolicy) == 0 { @@ -72,8 +72,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { s.Labels = s.Spec.Template.Labels } }, - func(j *apps.Deployment, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *apps.Deployment, c randfill.Continue) { + c.FillNoCustom(j) // match defaulting if j.Spec.Selector == nil { @@ -83,15 +83,15 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { j.Labels = j.Spec.Template.Labels } }, - func(j *apps.DeploymentSpec, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *apps.DeploymentSpec, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again rhl := int32(c.Rand.Int31()) pds := int32(c.Rand.Int31()) j.RevisionHistoryLimit = &rhl j.ProgressDeadlineSeconds = &pds }, - func(j *apps.DeploymentStrategy, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *apps.DeploymentStrategy, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again // Ensure that strategyType is one of valid values. strategyTypes := []apps.DeploymentStrategyType{apps.RecreateDeploymentStrategyType, apps.RollingUpdateDeploymentStrategyType} j.Type = strategyTypes[c.Rand.Intn(len(strategyTypes))] @@ -99,7 +99,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { j.RollingUpdate = nil } else { rollingUpdate := apps.RollingUpdateDeployment{} - if c.RandBool() { + if c.Bool() { rollingUpdate.MaxUnavailable = intstr.FromInt32(c.Rand.Int31()) rollingUpdate.MaxSurge = intstr.FromInt32(c.Rand.Int31()) } else { @@ -108,8 +108,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { j.RollingUpdate = &rollingUpdate } }, - func(j *apps.DaemonSet, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *apps.DaemonSet, c randfill.Continue) { + c.FillNoCustom(j) // match defaulter j.Spec.Template.Generation = 0 @@ -117,13 +117,13 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { j.ObjectMeta.Labels = j.Spec.Template.ObjectMeta.Labels } }, - func(j *apps.DaemonSetSpec, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *apps.DaemonSetSpec, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again rhl := int32(c.Rand.Int31()) j.RevisionHistoryLimit = &rhl }, - func(j *apps.DaemonSetUpdateStrategy, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *apps.DaemonSetUpdateStrategy, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again // Ensure that strategyType is one of valid values. strategyTypes := []apps.DaemonSetUpdateStrategyType{apps.RollingUpdateDaemonSetStrategyType, apps.OnDeleteDaemonSetStrategyType} j.Type = strategyTypes[c.Rand.Intn(len(strategyTypes))] @@ -131,8 +131,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { j.RollingUpdate = nil } else { rollingUpdate := apps.RollingUpdateDaemonSet{} - if c.RandBool() { - if c.RandBool() { + if c.Bool() { + if c.Bool() { rollingUpdate.MaxUnavailable = intstr.FromInt32(c.Rand.Int31()) rollingUpdate.MaxSurge = intstr.FromInt32(c.Rand.Int31()) } else { @@ -143,8 +143,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { j.RollingUpdate = &rollingUpdate } }, - func(j *apps.ReplicaSet, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *apps.ReplicaSet, c randfill.Continue) { + c.FillNoCustom(j) // match defaulter if j.Spec.Selector == nil { diff --git a/pkg/apis/autoscaling/fuzzer/fuzzer.go b/pkg/apis/autoscaling/fuzzer/fuzzer.go index 6a9cbc71402..64585593ef0 100644 --- a/pkg/apis/autoscaling/fuzzer/fuzzer.go +++ b/pkg/apis/autoscaling/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,22 +30,22 @@ import ( // Funcs returns the fuzzer functions for the autoscaling api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *autoscaling.ScaleStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *autoscaling.ScaleStatus, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again // ensure we have a valid selector metaSelector := &metav1.LabelSelector{} - c.Fuzz(metaSelector) + c.Fill(metaSelector) labelSelector, _ := metav1.LabelSelectorAsSelector(metaSelector) s.Selector = labelSelector.String() }, - func(s *autoscaling.HorizontalPodAutoscalerSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *autoscaling.HorizontalPodAutoscalerSpec, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again s.MinReplicas = pointer.Int32(c.Rand.Int31()) randomQuantity := func() resource.Quantity { var q resource.Quantity - c.Fuzz(&q) + c.Fill(&q) // precalc the string for benchmarking purposes _ = q.String() return q @@ -53,10 +53,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { var podMetricID autoscaling.MetricIdentifier var objMetricID autoscaling.MetricIdentifier - c.Fuzz(&podMetricID) - c.Fuzz(&objMetricID) + c.Fill(&podMetricID) + c.Fill(&objMetricID) - targetUtilization := int32(c.RandUint64()) + targetUtilization := int32(c.Uint64()) averageValue := randomQuantity() s.Metrics = []autoscaling.MetricSpec{ { @@ -90,7 +90,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { }, }, } - stabilizationWindow := int32(c.RandUint64()) + stabilizationWindow := int32(c.Uint64()) maxPolicy := autoscaling.MaxPolicySelect minPolicy := autoscaling.MinPolicySelect s.Behavior = &autoscaling.HorizontalPodAutoscalerBehavior{ @@ -100,13 +100,13 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { Policies: []autoscaling.HPAScalingPolicy{ { Type: autoscaling.PodsScalingPolicy, - Value: int32(c.RandUint64()), - PeriodSeconds: int32(c.RandUint64()), + Value: int32(c.Uint64()), + PeriodSeconds: int32(c.Uint64()), }, { Type: autoscaling.PercentScalingPolicy, - Value: int32(c.RandUint64()), - PeriodSeconds: int32(c.RandUint64()), + Value: int32(c.Uint64()), + PeriodSeconds: int32(c.Uint64()), }, }, }, @@ -116,35 +116,35 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { Policies: []autoscaling.HPAScalingPolicy{ { Type: autoscaling.PodsScalingPolicy, - Value: int32(c.RandUint64()), - PeriodSeconds: int32(c.RandUint64()), + Value: int32(c.Uint64()), + PeriodSeconds: int32(c.Uint64()), }, { Type: autoscaling.PercentScalingPolicy, - Value: int32(c.RandUint64()), - PeriodSeconds: int32(c.RandUint64()), + Value: int32(c.Uint64()), + PeriodSeconds: int32(c.Uint64()), }, }, }, } }, - func(s *autoscaling.HorizontalPodAutoscalerStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *autoscaling.HorizontalPodAutoscalerStatus, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again randomQuantity := func() resource.Quantity { var q resource.Quantity - c.Fuzz(&q) + c.Fill(&q) // precalc the string for benchmarking purposes _ = q.String() return q } averageValue := randomQuantity() - currentUtilization := int32(c.RandUint64()) + currentUtilization := int32(c.Uint64()) s.CurrentMetrics = []autoscaling.MetricStatus{ { Type: autoscaling.PodsMetricSourceType, Pods: &autoscaling.PodsMetricStatus{ Metric: autoscaling.MetricIdentifier{ - Name: c.RandString(), + Name: c.String(0), }, Current: autoscaling.MetricValueStatus{ AverageValue: &averageValue, diff --git a/pkg/apis/batch/fuzzer/fuzzer.go b/pkg/apis/batch/fuzzer/fuzzer.go index dc18c157ac5..735cb0f6012 100644 --- a/pkg/apis/batch/fuzzer/fuzzer.go +++ b/pkg/apis/batch/fuzzer/fuzzer.go @@ -19,73 +19,73 @@ package fuzzer import ( "math" - fuzz "github.com/google/gofuzz" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/batch" api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/utils/pointer" + "sigs.k8s.io/randfill" ) // Funcs returns the fuzzer functions for the batch api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(j *batch.Job, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *batch.Job, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again // match defaulting if len(j.Labels) == 0 { j.Labels = j.Spec.Template.Labels } }, - func(j *batch.JobSpec, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *batch.JobSpec, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again completions := int32(c.Rand.Int31()) parallelism := int32(c.Rand.Int31()) backoffLimit := int32(c.Rand.Int31()) j.Completions = &completions j.Parallelism = ¶llelism j.BackoffLimit = &backoffLimit - j.ManualSelector = pointer.Bool(c.RandBool()) + j.ManualSelector = pointer.Bool(c.Bool()) mode := batch.NonIndexedCompletion - if c.RandBool() { + if c.Bool() { mode = batch.IndexedCompletion j.BackoffLimitPerIndex = pointer.Int32(c.Rand.Int31()) j.MaxFailedIndexes = pointer.Int32(c.Rand.Int31()) } - if c.RandBool() { + if c.Bool() { j.BackoffLimit = pointer.Int32(math.MaxInt32) } j.CompletionMode = &mode // We're fuzzing the internal JobSpec type, not the v1 type, so we don't // need to fuzz the nil value. - j.Suspend = pointer.Bool(c.RandBool()) + j.Suspend = pointer.Bool(c.Bool()) podReplacementPolicy := batch.TerminatingOrFailed - if c.RandBool() { + if c.Bool() { podReplacementPolicy = batch.Failed } j.PodReplacementPolicy = &podReplacementPolicy - if c.RandBool() { - c.Fuzz(j.ManagedBy) + if c.Bool() { + c.Fill(j.ManagedBy) } }, - func(sj *batch.CronJobSpec, c fuzz.Continue) { - c.FuzzNoCustom(sj) - suspend := c.RandBool() + func(sj *batch.CronJobSpec, c randfill.Continue) { + c.FillNoCustom(sj) + suspend := c.Bool() sj.Suspend = &suspend - sds := int64(c.RandUint64()) + sds := int64(c.Uint64()) sj.StartingDeadlineSeconds = &sds - sj.Schedule = c.RandString() + sj.Schedule = c.String(0) successfulJobsHistoryLimit := int32(c.Rand.Int31()) sj.SuccessfulJobsHistoryLimit = &successfulJobsHistoryLimit failedJobsHistoryLimit := int32(c.Rand.Int31()) sj.FailedJobsHistoryLimit = &failedJobsHistoryLimit }, - func(cp *batch.ConcurrencyPolicy, c fuzz.Continue) { + func(cp *batch.ConcurrencyPolicy, c randfill.Continue) { policies := []batch.ConcurrencyPolicy{batch.AllowConcurrent, batch.ForbidConcurrent, batch.ReplaceConcurrent} *cp = policies[c.Rand.Intn(len(policies))] }, - func(p *batch.PodFailurePolicyOnPodConditionsPattern, c fuzz.Continue) { - c.FuzzNoCustom(p) + func(p *batch.PodFailurePolicyOnPodConditionsPattern, c randfill.Continue) { + c.FillNoCustom(p) if p.Status == "" { p.Status = api.ConditionTrue } diff --git a/pkg/apis/certificates/fuzzer/fuzzer.go b/pkg/apis/certificates/fuzzer/fuzzer.go index c9711eb7f37..dfb72d0cc71 100644 --- a/pkg/apis/certificates/fuzzer/fuzzer.go +++ b/pkg/apis/certificates/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/client-go/util/certificate/csr" @@ -30,14 +30,14 @@ import ( // Funcs returns the fuzzer functions for the certificates api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *certificates.CertificateSigningRequestSpec, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *certificates.CertificateSigningRequestSpec, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again obj.Usages = []certificates.KeyUsage{certificates.UsageKeyEncipherment} obj.SignerName = "example.com/custom-sample-signer" obj.ExpirationSeconds = csr.DurationToExpirationSeconds(time.Hour + time.Minute + time.Second) }, - func(obj *certificates.CertificateSigningRequestCondition, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *certificates.CertificateSigningRequestCondition, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if len(obj.Status) == 0 { obj.Status = api.ConditionTrue } diff --git a/pkg/apis/core/fuzzer/fuzzer.go b/pkg/apis/core/fuzzer/fuzzer.go index a02f4151d78..99ab79c713b 100644 --- a/pkg/apis/core/fuzzer/fuzzer.go +++ b/pkg/apis/core/fuzzer/fuzzer.go @@ -21,7 +21,7 @@ import ( "strconv" "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -37,45 +37,45 @@ import ( // Funcs returns the fuzzer functions for the core group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(q *resource.Quantity, c fuzz.Continue) { + func(q *resource.Quantity, c randfill.Continue) { *q = *resource.NewQuantity(c.Int63n(1000), resource.DecimalExponent) }, - func(j *core.ObjectReference, c fuzz.Continue) { + func(j *core.ObjectReference, c randfill.Continue) { // We have to customize the randomization of TypeMetas because their // APIVersion and Kind must remain blank in memory. - j.APIVersion = c.RandString() - j.Kind = c.RandString() - j.Namespace = c.RandString() - j.Name = c.RandString() - j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10) - j.FieldPath = c.RandString() + j.APIVersion = c.String(0) + j.Kind = c.String(0) + j.Namespace = c.String(0) + j.Name = c.String(0) + j.ResourceVersion = strconv.FormatUint(c.Uint64(), 10) + j.FieldPath = c.String(0) }, - func(j *core.PodExecOptions, c fuzz.Continue) { + func(j *core.PodExecOptions, c randfill.Continue) { j.Stdout = true j.Stderr = true }, - func(j *core.PodAttachOptions, c fuzz.Continue) { + func(j *core.PodAttachOptions, c randfill.Continue) { j.Stdout = true j.Stderr = true }, - func(j *core.PodPortForwardOptions, c fuzz.Continue) { - if c.RandBool() { + func(j *core.PodPortForwardOptions, c randfill.Continue) { + if c.Bool() { j.Ports = make([]int32, c.Intn(10)) for i := range j.Ports { j.Ports[i] = c.Int31n(65535) } } }, - func(s *core.PodSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *core.PodSpec, c randfill.Continue) { + c.FillNoCustom(s) // has a default value ttl := int64(30) - if c.RandBool() { + if c.Bool() { ttl = int64(c.Uint32()) } s.TerminationGracePeriodSeconds = &ttl - c.Fuzz(s.SecurityContext) + c.Fill(s.SecurityContext) if s.SecurityContext == nil { s.SecurityContext = new(core.PodSecurityContext) @@ -91,20 +91,20 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { s.EnableServiceLinks = &enableServiceLinks } }, - func(s *core.PodStatus, c fuzz.Continue) { - c.Fuzz(&s) + func(s *core.PodStatus, c randfill.Continue) { + c.Fill(&s) s.HostIPs = []core.HostIP{{IP: s.HostIP}} }, - func(j *core.PodPhase, c fuzz.Continue) { + func(j *core.PodPhase, c randfill.Continue) { statuses := []core.PodPhase{core.PodPending, core.PodRunning, core.PodFailed, core.PodUnknown} *j = statuses[c.Rand.Intn(len(statuses))] }, - func(j *core.Binding, c fuzz.Continue) { - c.Fuzz(&j.ObjectMeta) - j.Target.Name = c.RandString() + func(j *core.Binding, c randfill.Continue) { + c.Fill(&j.ObjectMeta) + j.Target.Name = c.String(0) }, - func(j *core.ReplicationController, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *core.ReplicationController, c randfill.Continue) { + c.FillNoCustom(j) // match defaulting if j.Spec.Template != nil { @@ -116,21 +116,21 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(j *core.ReplicationControllerSpec, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *core.ReplicationControllerSpec, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again //j.TemplateRef = nil // this is required for round trip }, - func(j *core.List, c fuzz.Continue) { - c.FuzzNoCustom(j) // fuzz self without calling this function again + func(j *core.List, c randfill.Continue) { + c.FillNoCustom(j) // fuzz self without calling this function again // TODO: uncomment when round trip starts from a versioned object if false { //j.Items == nil { j.Items = []runtime.Object{} } }, - func(q *core.ResourceRequirements, c fuzz.Continue) { + func(q *core.ResourceRequirements, c randfill.Continue) { randomQuantity := func() resource.Quantity { var q resource.Quantity - c.Fuzz(&q) + c.Fill(&q) // precalc the string for benchmarking purposes _ = q.String() return q @@ -147,9 +147,9 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { q.Limits[core.ResourceStorage] = storageLimit.DeepCopy() q.Requests[core.ResourceStorage] = storageLimit.DeepCopy() }, - func(q *core.LimitRangeItem, c fuzz.Continue) { + func(q *core.LimitRangeItem, c randfill.Continue) { var cpuLimit resource.Quantity - c.Fuzz(&cpuLimit) + c.Fill(&cpuLimit) q.Type = core.LimitTypeContainer q.Default = make(core.ResourceList) @@ -167,79 +167,79 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { q.MaxLimitRequestRatio = make(core.ResourceList) q.MaxLimitRequestRatio[core.ResourceCPU] = resource.MustParse("10") }, - func(p *core.PullPolicy, c fuzz.Continue) { + func(p *core.PullPolicy, c randfill.Continue) { policies := []core.PullPolicy{core.PullAlways, core.PullNever, core.PullIfNotPresent} *p = policies[c.Rand.Intn(len(policies))] }, - func(rp *core.RestartPolicy, c fuzz.Continue) { + func(rp *core.RestartPolicy, c randfill.Continue) { policies := []core.RestartPolicy{core.RestartPolicyAlways, core.RestartPolicyNever, core.RestartPolicyOnFailure} *rp = policies[c.Rand.Intn(len(policies))] }, // core.DownwardAPIVolumeFile needs to have a specific func since FieldRef has to be // defaulted to a version otherwise roundtrip will fail - func(m *core.DownwardAPIVolumeFile, c fuzz.Continue) { - m.Path = c.RandString() + func(m *core.DownwardAPIVolumeFile, c randfill.Continue) { + m.Path = c.String(0) versions := []string{"v1"} m.FieldRef = &core.ObjectFieldSelector{} m.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))] - m.FieldRef.FieldPath = c.RandString() - c.Fuzz(m.Mode) + m.FieldRef.FieldPath = c.String(0) + c.Fill(m.Mode) if m.Mode != nil { *m.Mode &= 0777 } }, - func(s *core.SecretVolumeSource, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *core.SecretVolumeSource, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again - if c.RandBool() { - opt := c.RandBool() + if c.Bool() { + opt := c.Bool() s.Optional = &opt } // DefaultMode should always be set, it has a default // value and it is expected to be between 0 and 0777 var mode int32 - c.Fuzz(&mode) + c.Fill(&mode) mode &= 0777 s.DefaultMode = &mode }, - func(cm *core.ConfigMapVolumeSource, c fuzz.Continue) { - c.FuzzNoCustom(cm) // fuzz self without calling this function again + func(cm *core.ConfigMapVolumeSource, c randfill.Continue) { + c.FillNoCustom(cm) // fuzz self without calling this function again - if c.RandBool() { - opt := c.RandBool() + if c.Bool() { + opt := c.Bool() cm.Optional = &opt } // DefaultMode should always be set, it has a default // value and it is expected to be between 0 and 0777 var mode int32 - c.Fuzz(&mode) + c.Fill(&mode) mode &= 0777 cm.DefaultMode = &mode }, - func(d *core.DownwardAPIVolumeSource, c fuzz.Continue) { - c.FuzzNoCustom(d) // fuzz self without calling this function again + func(d *core.DownwardAPIVolumeSource, c randfill.Continue) { + c.FillNoCustom(d) // fuzz self without calling this function again // DefaultMode should always be set, it has a default // value and it is expected to be between 0 and 0777 var mode int32 - c.Fuzz(&mode) + c.Fill(&mode) mode &= 0777 d.DefaultMode = &mode }, - func(s *core.ProjectedVolumeSource, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *core.ProjectedVolumeSource, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again // DefaultMode should always be set, it has a default // value and it is expected to be between 0 and 0777 var mode int32 - c.Fuzz(&mode) + c.Fill(&mode) mode &= 0777 s.DefaultMode = &mode }, - func(k *core.KeyToPath, c fuzz.Continue) { - c.FuzzNoCustom(k) // fuzz self without calling this function again - k.Key = c.RandString() - k.Path = c.RandString() + func(k *core.KeyToPath, c randfill.Continue) { + c.FillNoCustom(k) // fuzz self without calling this function again + k.Key = c.String(0) + k.Path = c.String(0) // Mode is not mandatory, but if it is set, it should be // a value between 0 and 0777 @@ -247,76 +247,76 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { *k.Mode &= 0777 } }, - func(vs *core.VolumeSource, c fuzz.Continue) { + func(vs *core.VolumeSource, c randfill.Continue) { // Exactly one of the fields must be set. v := reflect.ValueOf(vs).Elem() - i := int(c.RandUint64() % uint64(v.NumField())) + i := int(c.Uint64() % uint64(v.NumField())) t := v.Field(i).Addr() for v.Field(i).IsNil() { - c.Fuzz(t.Interface()) + c.Fill(t.Interface()) } }, - func(i *core.ISCSIVolumeSource, c fuzz.Continue) { - i.ISCSIInterface = c.RandString() + func(i *core.ISCSIVolumeSource, c randfill.Continue) { + i.ISCSIInterface = c.String(0) if i.ISCSIInterface == "" { i.ISCSIInterface = "default" } }, - func(i *core.ISCSIPersistentVolumeSource, c fuzz.Continue) { - i.ISCSIInterface = c.RandString() + func(i *core.ISCSIPersistentVolumeSource, c randfill.Continue) { + i.ISCSIInterface = c.String(0) if i.ISCSIInterface == "" { i.ISCSIInterface = "default" } }, - func(i *core.PersistentVolumeClaimSpec, c fuzz.Continue) { + func(i *core.PersistentVolumeClaimSpec, c randfill.Continue) { // Match defaulting in pkg/apis/core/v1/defaults.go. - volumeMode := core.PersistentVolumeMode(c.RandString()) + volumeMode := core.PersistentVolumeMode(c.String(0)) if volumeMode == "" { volumeMode = core.PersistentVolumeFilesystem } i.VolumeMode = &volumeMode }, - func(d *core.DNSPolicy, c fuzz.Continue) { + func(d *core.DNSPolicy, c randfill.Continue) { policies := []core.DNSPolicy{core.DNSClusterFirst, core.DNSDefault} *d = policies[c.Rand.Intn(len(policies))] }, - func(p *core.Protocol, c fuzz.Continue) { + func(p *core.Protocol, c randfill.Continue) { protocols := []core.Protocol{core.ProtocolTCP, core.ProtocolUDP, core.ProtocolSCTP} *p = protocols[c.Rand.Intn(len(protocols))] }, - func(p *core.ServiceAffinity, c fuzz.Continue) { + func(p *core.ServiceAffinity, c randfill.Continue) { types := []core.ServiceAffinity{core.ServiceAffinityClientIP, core.ServiceAffinityNone} *p = types[c.Rand.Intn(len(types))] }, - func(p *core.ServiceType, c fuzz.Continue) { + func(p *core.ServiceType, c randfill.Continue) { types := []core.ServiceType{core.ServiceTypeClusterIP, core.ServiceTypeNodePort, core.ServiceTypeLoadBalancer} *p = types[c.Rand.Intn(len(types))] }, - func(p *core.IPFamily, c fuzz.Continue) { + func(p *core.IPFamily, c randfill.Continue) { types := []core.IPFamily{core.IPv4Protocol, core.IPv6Protocol} selected := types[c.Rand.Intn(len(types))] *p = selected }, - func(p *core.ServiceExternalTrafficPolicy, c fuzz.Continue) { + func(p *core.ServiceExternalTrafficPolicy, c randfill.Continue) { types := []core.ServiceExternalTrafficPolicy{core.ServiceExternalTrafficPolicyCluster, core.ServiceExternalTrafficPolicyLocal} *p = types[c.Rand.Intn(len(types))] }, - func(p *core.ServiceInternalTrafficPolicy, c fuzz.Continue) { + func(p *core.ServiceInternalTrafficPolicy, c randfill.Continue) { types := []core.ServiceInternalTrafficPolicy{core.ServiceInternalTrafficPolicyCluster, core.ServiceInternalTrafficPolicyLocal} *p = types[c.Rand.Intn(len(types))] }, - func(ct *core.Container, c fuzz.Continue) { - c.FuzzNoCustom(ct) // fuzz self without calling this function again + func(ct *core.Container, c randfill.Continue) { + c.FillNoCustom(ct) // fuzz self without calling this function again ct.TerminationMessagePath = "/" + ct.TerminationMessagePath // Must be non-empty ct.TerminationMessagePolicy = "File" }, - func(ep *core.EphemeralContainer, c fuzz.Continue) { - c.FuzzNoCustom(ep) // fuzz self without calling this function again + func(ep *core.EphemeralContainer, c randfill.Continue) { + c.FillNoCustom(ep) // fuzz self without calling this function again ep.EphemeralContainerCommon.TerminationMessagePath = "/" + ep.TerminationMessagePath // Must be non-empty ep.EphemeralContainerCommon.TerminationMessagePolicy = "File" }, - func(p *core.Probe, c fuzz.Continue) { - c.FuzzNoCustom(p) + func(p *core.Probe, c randfill.Continue) { + c.FillNoCustom(p) // These fields have default values. intFieldsWithDefaults := [...]string{"TimeoutSeconds", "PeriodSeconds", "SuccessThreshold", "FailureThreshold"} v := reflect.ValueOf(p).Elem() @@ -327,10 +327,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(ev *core.EnvVar, c fuzz.Continue) { - ev.Name = c.RandString() - if c.RandBool() { - ev.Value = c.RandString() + func(ev *core.EnvVar, c randfill.Continue) { + ev.Name = c.String(0) + if c.Bool() { + ev.Value = c.String(0) } else { ev.ValueFrom = &core.EnvVarSource{} ev.ValueFrom.FieldRef = &core.ObjectFieldSelector{} @@ -343,79 +343,79 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } ev.ValueFrom.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))].String() - ev.ValueFrom.FieldRef.FieldPath = c.RandString() + ev.ValueFrom.FieldRef.FieldPath = c.String(0) } }, - func(ev *core.EnvFromSource, c fuzz.Continue) { - if c.RandBool() { + func(ev *core.EnvFromSource, c randfill.Continue) { + if c.Bool() { ev.Prefix = "p_" } - if c.RandBool() { - c.Fuzz(&ev.ConfigMapRef) + if c.Bool() { + c.Fill(&ev.ConfigMapRef) } else { - c.Fuzz(&ev.SecretRef) + c.Fill(&ev.SecretRef) } }, - func(cm *core.ConfigMapEnvSource, c fuzz.Continue) { - c.FuzzNoCustom(cm) // fuzz self without calling this function again - if c.RandBool() { - opt := c.RandBool() + func(cm *core.ConfigMapEnvSource, c randfill.Continue) { + c.FillNoCustom(cm) // fuzz self without calling this function again + if c.Bool() { + opt := c.Bool() cm.Optional = &opt } }, - func(s *core.SecretEnvSource, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *core.SecretEnvSource, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again }, - func(sc *core.SecurityContext, c fuzz.Continue) { - c.FuzzNoCustom(sc) // fuzz self without calling this function again - if c.RandBool() { - priv := c.RandBool() + func(sc *core.SecurityContext, c randfill.Continue) { + c.FillNoCustom(sc) // fuzz self without calling this function again + if c.Bool() { + priv := c.Bool() sc.Privileged = &priv } - if c.RandBool() { + if c.Bool() { sc.Capabilities = &core.Capabilities{ Add: make([]core.Capability, 0), Drop: make([]core.Capability, 0), } - c.Fuzz(&sc.Capabilities.Add) - c.Fuzz(&sc.Capabilities.Drop) + c.Fill(&sc.Capabilities.Add) + c.Fill(&sc.Capabilities.Drop) } }, - func(s *core.Secret, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *core.Secret, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again s.Type = core.SecretTypeOpaque }, - func(r *core.RBDVolumeSource, c fuzz.Continue) { - r.RBDPool = c.RandString() + func(r *core.RBDVolumeSource, c randfill.Continue) { + r.RBDPool = c.String(0) if r.RBDPool == "" { r.RBDPool = "rbd" } - r.RadosUser = c.RandString() + r.RadosUser = c.String(0) if r.RadosUser == "" { r.RadosUser = "admin" } - r.Keyring = c.RandString() + r.Keyring = c.String(0) if r.Keyring == "" { r.Keyring = "/etc/ceph/keyring" } }, - func(r *core.RBDPersistentVolumeSource, c fuzz.Continue) { - r.RBDPool = c.RandString() + func(r *core.RBDPersistentVolumeSource, c randfill.Continue) { + r.RBDPool = c.String(0) if r.RBDPool == "" { r.RBDPool = "rbd" } - r.RadosUser = c.RandString() + r.RadosUser = c.String(0) if r.RadosUser == "" { r.RadosUser = "admin" } - r.Keyring = c.RandString() + r.Keyring = c.String(0) if r.Keyring == "" { r.Keyring = "/etc/ceph/keyring" } }, - func(obj *core.HostPathVolumeSource, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *core.HostPathVolumeSource, c randfill.Continue) { + c.FillNoCustom(obj) types := []core.HostPathType{core.HostPathUnset, core.HostPathDirectoryOrCreate, core.HostPathDirectory, core.HostPathFileOrCreate, core.HostPathFile, core.HostPathSocket, core.HostPathCharDev, core.HostPathBlockDev} typeVol := types[c.Rand.Intn(len(types))] @@ -423,24 +423,24 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { obj.Type = &typeVol } }, - func(pv *core.PersistentVolume, c fuzz.Continue) { - c.FuzzNoCustom(pv) // fuzz self without calling this function again + func(pv *core.PersistentVolume, c randfill.Continue) { + c.FillNoCustom(pv) // fuzz self without calling this function again types := []core.PersistentVolumePhase{core.VolumeAvailable, core.VolumePending, core.VolumeBound, core.VolumeReleased, core.VolumeFailed} pv.Status.Phase = types[c.Rand.Intn(len(types))] - pv.Status.Message = c.RandString() + pv.Status.Message = c.String(0) reclamationPolicies := []core.PersistentVolumeReclaimPolicy{core.PersistentVolumeReclaimRecycle, core.PersistentVolumeReclaimRetain} pv.Spec.PersistentVolumeReclaimPolicy = reclamationPolicies[c.Rand.Intn(len(reclamationPolicies))] volumeModes := []core.PersistentVolumeMode{core.PersistentVolumeFilesystem, core.PersistentVolumeBlock} pv.Spec.VolumeMode = &volumeModes[c.Rand.Intn(len(volumeModes))] }, - func(pvc *core.PersistentVolumeClaim, c fuzz.Continue) { - c.FuzzNoCustom(pvc) // fuzz self without calling this function again + func(pvc *core.PersistentVolumeClaim, c randfill.Continue) { + c.FillNoCustom(pvc) // fuzz self without calling this function again types := []core.PersistentVolumeClaimPhase{core.ClaimBound, core.ClaimPending, core.ClaimLost} pvc.Status.Phase = types[c.Rand.Intn(len(types))] volumeModes := []core.PersistentVolumeMode{core.PersistentVolumeFilesystem, core.PersistentVolumeBlock} pvc.Spec.VolumeMode = &volumeModes[c.Rand.Intn(len(volumeModes))] }, - func(obj *core.AzureDiskVolumeSource, c fuzz.Continue) { + func(obj *core.AzureDiskVolumeSource, c randfill.Continue) { if obj.CachingMode == nil { obj.CachingMode = new(core.AzureDataDiskCachingMode) *obj.CachingMode = core.AzureDataDiskCachingReadWrite @@ -458,31 +458,31 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { *obj.ReadOnly = false } }, - func(sio *core.ScaleIOVolumeSource, c fuzz.Continue) { - sio.StorageMode = c.RandString() + func(sio *core.ScaleIOVolumeSource, c randfill.Continue) { + sio.StorageMode = c.String(0) if sio.StorageMode == "" { sio.StorageMode = "ThinProvisioned" } - sio.FSType = c.RandString() + sio.FSType = c.String(0) if sio.FSType == "" { sio.FSType = "xfs" } }, - func(sio *core.ScaleIOPersistentVolumeSource, c fuzz.Continue) { - sio.StorageMode = c.RandString() + func(sio *core.ScaleIOPersistentVolumeSource, c randfill.Continue) { + sio.StorageMode = c.String(0) if sio.StorageMode == "" { sio.StorageMode = "ThinProvisioned" } - sio.FSType = c.RandString() + sio.FSType = c.String(0) if sio.FSType == "" { sio.FSType = "xfs" } }, - func(s *core.NamespaceSpec, c fuzz.Continue) { + func(s *core.NamespaceSpec, c randfill.Continue) { s.Finalizers = []core.FinalizerName{core.FinalizerKubernetes} }, - func(s *core.Namespace, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *core.Namespace, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again // Match name --> label defaulting if len(s.Name) > 0 { if s.Labels == nil { @@ -491,20 +491,20 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { s.Labels["kubernetes.io/metadata.name"] = s.Name } }, - func(s *core.NamespaceStatus, c fuzz.Continue) { + func(s *core.NamespaceStatus, c randfill.Continue) { s.Phase = core.NamespaceActive }, - func(http *core.HTTPGetAction, c fuzz.Continue) { - c.FuzzNoCustom(http) // fuzz self without calling this function again + func(http *core.HTTPGetAction, c randfill.Continue) { + c.FillNoCustom(http) // fuzz self without calling this function again http.Path = "/" + http.Path // can't be blank http.Scheme = "x" + http.Scheme // can't be blank }, - func(ss *core.ServiceSpec, c fuzz.Continue) { - c.FuzzNoCustom(ss) // fuzz self without calling this function again + func(ss *core.ServiceSpec, c randfill.Continue) { + c.FillNoCustom(ss) // fuzz self without calling this function again if len(ss.Ports) == 0 { // There must be at least 1 port. ss.Ports = append(ss.Ports, core.ServicePort{}) - c.Fuzz(&ss.Ports[0]) + c.Fill(&ss.Ports[0]) } for i := range ss.Ports { switch ss.Ports[i].TargetPort.Type { @@ -531,24 +531,24 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { ss.AllocateLoadBalancerNodePorts = utilpointer.Bool(true) } }, - func(s *core.NodeStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *core.NodeStatus, c randfill.Continue) { + c.FillNoCustom(s) s.Allocatable = s.Capacity }, - func(e *core.Event, c fuzz.Continue) { - c.FuzzNoCustom(e) + func(e *core.Event, c randfill.Continue) { + c.FillNoCustom(e) e.EventTime = metav1.MicroTime{Time: time.Unix(1, 1000)} if e.Series != nil { e.Series.LastObservedTime = metav1.MicroTime{Time: time.Unix(3, 3000)} } }, - func(j *core.GRPCAction, c fuzz.Continue) { + func(j *core.GRPCAction, c randfill.Continue) { empty := "" if j.Service == nil { j.Service = &empty } }, - func(j *core.LoadBalancerStatus, c fuzz.Continue) { + func(j *core.LoadBalancerStatus, c randfill.Continue) { ipMode := core.LoadBalancerIPModeVIP for i := range j.Ingress { if j.Ingress[i].IPMode == nil { diff --git a/pkg/apis/core/v1/conversion_test.go b/pkg/apis/core/v1/conversion_test.go index 523848c7f56..7df4b846441 100644 --- a/pkg/apis/core/v1/conversion_test.go +++ b/pkg/apis/core/v1/conversion_test.go @@ -292,7 +292,7 @@ func TestReplicationControllerConversion(t *testing.T) { apiObjectFuzzer := fuzzer.FuzzerFor(fuzzer.MergeFuzzerFuncs(metafuzzer.Funcs, corefuzzer.Funcs), rand.NewSource(152), legacyscheme.Codecs) for i := 0; i < 100; i++ { rc := &v1.ReplicationController{} - apiObjectFuzzer.Fuzz(rc) + apiObjectFuzzer.Fill(rc) // Sometimes the fuzzer decides to leave Spec.Template nil. // We can't support that because Spec.Template is not a pointer in RS, // so it will round-trip as non-nil but empty. diff --git a/pkg/apis/discovery/fuzzer/fuzzer.go b/pkg/apis/discovery/fuzzer/fuzzer.go index b69490a7842..cbb5ba4a83d 100644 --- a/pkg/apis/discovery/fuzzer/fuzzer.go +++ b/pkg/apis/discovery/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" api "k8s.io/kubernetes/pkg/apis/core" @@ -27,8 +27,8 @@ import ( // Funcs returns the fuzzer functions for the discovery api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *discovery.EndpointSlice, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *discovery.EndpointSlice, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again addressTypes := []discovery.AddressType{discovery.AddressTypeIPv4, discovery.AddressTypeIPv6, discovery.AddressTypeFQDN} obj.AddressType = addressTypes[c.Rand.Intn(len(addressTypes))] diff --git a/pkg/apis/flowcontrol/fuzzer/fuzzer.go b/pkg/apis/flowcontrol/fuzzer/fuzzer.go index 3d6d4da28ea..f31f2e27f9d 100644 --- a/pkg/apis/flowcontrol/fuzzer/fuzzer.go +++ b/pkg/apis/flowcontrol/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/flowcontrol" @@ -27,8 +27,8 @@ import ( // Funcs returns the fuzzer functions for the flowcontrol api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *flowcontrol.LimitedPriorityLevelConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *flowcontrol.LimitedPriorityLevelConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again // NOTE: setting a zero value here will cause the roundtrip // test (from internal to v1beta2, v1beta1) to fail @@ -39,8 +39,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { obj.LendablePercent = ptr.To(int32(0)) } }, - func(obj *flowcontrol.ExemptPriorityLevelConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *flowcontrol.ExemptPriorityLevelConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again if obj.NominalConcurrencyShares == nil { obj.NominalConcurrencyShares = ptr.To(int32(0)) } diff --git a/pkg/apis/networking/fuzzer/fuzzer.go b/pkg/apis/networking/fuzzer/fuzzer.go index 900979c4a77..a0a5c709aa9 100644 --- a/pkg/apis/networking/fuzzer/fuzzer.go +++ b/pkg/apis/networking/fuzzer/fuzzer.go @@ -20,17 +20,17 @@ import ( "fmt" "net/netip" - fuzz "github.com/google/gofuzz" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/networking" utilpointer "k8s.io/utils/pointer" + "sigs.k8s.io/randfill" ) // Funcs returns the fuzzer functions for the networking api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(np *networking.NetworkPolicyPeer, c fuzz.Continue) { - c.FuzzNoCustom(np) // fuzz self without calling this function again + func(np *networking.NetworkPolicyPeer, c randfill.Continue) { + c.FillNoCustom(np) // fuzz self without calling this function again // TODO: Implement a fuzzer to generate valid keys, values and operators for // selector requirements. if np.IPBlock != nil { @@ -40,23 +40,23 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(np *networking.NetworkPolicy, c fuzz.Continue) { - c.FuzzNoCustom(np) // fuzz self without calling this function again + func(np *networking.NetworkPolicy, c randfill.Continue) { + c.FillNoCustom(np) // fuzz self without calling this function again // TODO: Implement a fuzzer to generate valid keys, values and operators for // selector requirements. if len(np.Spec.PolicyTypes) == 0 { np.Spec.PolicyTypes = []networking.PolicyType{networking.PolicyTypeIngress} } }, - func(path *networking.HTTPIngressPath, c fuzz.Continue) { - c.FuzzNoCustom(path) // fuzz self without calling this function again + func(path *networking.HTTPIngressPath, c randfill.Continue) { + c.FillNoCustom(path) // fuzz self without calling this function again pathTypes := []networking.PathType{networking.PathTypeExact, networking.PathTypePrefix, networking.PathTypeImplementationSpecific} path.PathType = &pathTypes[c.Rand.Intn(len(pathTypes))] }, - func(p *networking.ServiceBackendPort, c fuzz.Continue) { - c.FuzzNoCustom(p) + func(p *networking.ServiceBackendPort, c randfill.Continue) { + c.FillNoCustom(p) // clear one of the fields - if c.RandBool() { + if c.Bool() { p.Name = "" if p.Number == 0 { p.Number = 1 @@ -68,8 +68,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(p *networking.IngressClass, c fuzz.Continue) { - c.FuzzNoCustom(p) // fuzz self without calling this function again + func(p *networking.IngressClass, c randfill.Continue) { + c.FillNoCustom(p) // fuzz self without calling this function again // default Parameters to Cluster if p.Spec.Parameters == nil || p.Spec.Parameters.Scope == nil { p.Spec.Parameters = &networking.IngressClassParametersReference{ @@ -77,16 +77,16 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(obj *networking.IPAddress, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *networking.IPAddress, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again // length in bytes of the IP Family: IPv4: 4 bytes IPv6: 16 bytes boolean := []bool{false, true} is6 := boolean[c.Rand.Intn(2)] ip := generateRandomIP(is6, c) obj.Name = ip }, - func(obj *networking.ServiceCIDR, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *networking.ServiceCIDR, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again boolean := []bool{false, true} is6 := boolean[c.Rand.Intn(2)] @@ -100,7 +100,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } } -func generateRandomIP(is6 bool, c fuzz.Continue) string { +func generateRandomIP(is6 bool, c randfill.Continue) string { n := 4 if is6 { n = 16 @@ -118,7 +118,7 @@ func generateRandomIP(is6 bool, c fuzz.Continue) string { panic(fmt.Sprintf("invalid IP %v", bytes)) } -func generateRandomCIDR(is6 bool, c fuzz.Continue) string { +func generateRandomCIDR(is6 bool, c randfill.Continue) string { ip, err := netip.ParseAddr(generateRandomIP(is6, c)) if err != nil { // generateRandomIP already panics if returns a not valid ip diff --git a/pkg/apis/policy/fuzzer/fuzzer.go b/pkg/apis/policy/fuzzer/fuzzer.go index a7e852b0356..415bfb6082a 100644 --- a/pkg/apis/policy/fuzzer/fuzzer.go +++ b/pkg/apis/policy/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/policy" @@ -26,8 +26,8 @@ import ( // Funcs returns the fuzzer functions for the policy api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *policy.PodDisruptionBudgetStatus, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *policy.PodDisruptionBudgetStatus, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again s.DisruptionsAllowed = int32(c.Rand.Intn(2)) }, } diff --git a/pkg/apis/rbac/fuzzer/fuzzer.go b/pkg/apis/rbac/fuzzer/fuzzer.go index ca8f462ec54..9374f508326 100644 --- a/pkg/apis/rbac/fuzzer/fuzzer.go +++ b/pkg/apis/rbac/fuzzer/fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/rbac" @@ -26,33 +26,33 @@ import ( // Funcs returns the fuzzer functions for the rbac api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(r *rbac.RoleRef, c fuzz.Continue) { - c.FuzzNoCustom(r) // fuzz self without calling this function again + func(r *rbac.RoleRef, c randfill.Continue) { + c.FillNoCustom(r) // fuzz self without calling this function again // match defaulter if len(r.APIGroup) == 0 { r.APIGroup = rbac.GroupName } }, - func(r *rbac.Subject, c fuzz.Continue) { + func(r *rbac.Subject, c randfill.Continue) { switch c.Int31n(3) { case 0: r.Kind = rbac.ServiceAccountKind r.APIGroup = "" - c.FuzzNoCustom(&r.Name) - c.FuzzNoCustom(&r.Namespace) + c.FillNoCustom(&r.Name) + c.FillNoCustom(&r.Namespace) case 1: r.Kind = rbac.UserKind r.APIGroup = rbac.GroupName - c.FuzzNoCustom(&r.Name) + c.FillNoCustom(&r.Name) // user "*" won't round trip because we convert it to the system:authenticated group. try again. for r.Name == "*" { - c.FuzzNoCustom(&r.Name) + c.FillNoCustom(&r.Name) } case 2: r.Kind = rbac.GroupKind r.APIGroup = rbac.GroupName - c.FuzzNoCustom(&r.Name) + c.FillNoCustom(&r.Name) } }, } diff --git a/pkg/apis/resource/fuzzer/fuzzer.go b/pkg/apis/resource/fuzzer/fuzzer.go index f9fa97a102a..f3203dc6dff 100644 --- a/pkg/apis/resource/fuzzer/fuzzer.go +++ b/pkg/apis/resource/fuzzer/fuzzer.go @@ -17,10 +17,10 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/resource" + "sigs.k8s.io/randfill" ) // Funcs contains the fuzzer functions for the resource group. @@ -29,8 +29,8 @@ import ( // leads to errors during roundtrip tests. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(r *resource.DeviceRequest, c fuzz.Continue) { - c.FuzzNoCustom(r) // fuzz self without calling this function again + func(r *resource.DeviceRequest, c randfill.Continue) { + c.FillNoCustom(r) // fuzz self without calling this function again if r.AllocationMode == "" { r.AllocationMode = []resource.DeviceAllocationMode{ @@ -39,8 +39,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { }[c.Int31n(2)] } }, - func(r *resource.DeviceAllocationConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(r) + func(r *resource.DeviceAllocationConfiguration, c randfill.Continue) { + c.FillNoCustom(r) if r.Source == "" { r.Source = []resource.AllocationConfigSource{ resource.AllocationConfigSourceClass, @@ -48,16 +48,16 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { }[c.Int31n(2)] } }, - func(r *resource.OpaqueDeviceConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(r) + func(r *resource.OpaqueDeviceConfiguration, c randfill.Continue) { + c.FillNoCustom(r) // Match the fuzzer default content for runtime.Object. // // This is necessary because randomly generated content // might be valid JSON which changes during re-encoding. r.Parameters = runtime.RawExtension{Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`)} }, - func(r *resource.AllocatedDeviceStatus, c fuzz.Continue) { - c.FuzzNoCustom(r) + func(r *resource.AllocatedDeviceStatus, c randfill.Continue) { + c.FillNoCustom(r) // Match the fuzzer default content for runtime.Object. // // This is necessary because randomly generated content diff --git a/pkg/apis/scheduling/fuzzer/fuzzer.go b/pkg/apis/scheduling/fuzzer/fuzzer.go index f2cb549d301..794723bc93c 100644 --- a/pkg/apis/scheduling/fuzzer/fuzzer.go +++ b/pkg/apis/scheduling/fuzzer/fuzzer.go @@ -17,17 +17,17 @@ limitations under the License. package fuzzer import ( - "github.com/google/gofuzz" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/apis/scheduling" + "sigs.k8s.io/randfill" ) // Funcs returns the fuzzer functions for the scheduling api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *scheduling.PriorityClass, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *scheduling.PriorityClass, c randfill.Continue) { + c.FillNoCustom(s) if s.PreemptionPolicy == nil { preemptLowerPriority := core.PreemptLowerPriority s.PreemptionPolicy = &preemptLowerPriority diff --git a/pkg/apis/storage/fuzzer/fuzzer.go b/pkg/apis/storage/fuzzer/fuzzer.go index 5d122dbd232..9351a1dedc7 100644 --- a/pkg/apis/storage/fuzzer/fuzzer.go +++ b/pkg/apis/storage/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "fmt" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" api "k8s.io/kubernetes/pkg/apis/core" @@ -29,15 +29,15 @@ import ( // Funcs returns the fuzzer functions for the storage api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *storage.StorageClass, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *storage.StorageClass, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again reclamationPolicies := []api.PersistentVolumeReclaimPolicy{api.PersistentVolumeReclaimDelete, api.PersistentVolumeReclaimRetain} obj.ReclaimPolicy = &reclamationPolicies[c.Rand.Intn(len(reclamationPolicies))] bindingModes := []storage.VolumeBindingMode{storage.VolumeBindingImmediate, storage.VolumeBindingWaitForFirstConsumer} obj.VolumeBindingMode = &bindingModes[c.Rand.Intn(len(bindingModes))] }, - func(obj *storage.CSIDriver, c fuzz.Continue) { - c.FuzzNoCustom(obj) // fuzz self without calling this function again + func(obj *storage.CSIDriver, c randfill.Continue) { + c.FillNoCustom(obj) // fuzz self without calling this function again // Custom fuzzing for volume modes. switch c.Rand.Intn(7) { diff --git a/pkg/controller/apis/config/fuzzer/fuzzer.go b/pkg/controller/apis/config/fuzzer/fuzzer.go index 2aaecf6f3f5..afc5f2339c3 100644 --- a/pkg/controller/apis/config/fuzzer/fuzzer.go +++ b/pkg/controller/apis/config/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "fmt" - "github.com/google/gofuzz" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" @@ -28,20 +28,20 @@ import ( // Funcs returns the fuzzer functions for the kube-controller manager apis. func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *kubectrlmgrconfig.KubeControllerManagerConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *kubectrlmgrconfig.KubeControllerManagerConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) obj.Generic.Address = fmt.Sprintf("%d.%d.%d.%d", c.Intn(256), c.Intn(256), c.Intn(256), c.Intn(256)) - obj.Generic.ClientConnection.ContentType = fmt.Sprintf("%s/%s.%s.%s", c.RandString(), c.RandString(), c.RandString(), c.RandString()) + obj.Generic.ClientConnection.ContentType = fmt.Sprintf("%s/%s.%s.%s", c.String(0), c.String(0), c.String(0), c.String(0)) if obj.Generic.LeaderElection.ResourceLock == "" { obj.Generic.LeaderElection.ResourceLock = "endpoints" } - obj.Generic.Controllers = []string{fmt.Sprintf("%s", c.RandString())} + obj.Generic.Controllers = []string{c.String(0)} if obj.KubeCloudShared.ClusterName == "" { obj.KubeCloudShared.ClusterName = "kubernetes" } - obj.CSRSigningController.ClusterSigningCertFile = fmt.Sprintf("/%s", c.RandString()) - obj.CSRSigningController.ClusterSigningKeyFile = fmt.Sprintf("/%s", c.RandString()) - obj.PersistentVolumeBinderController.VolumeConfiguration.FlexVolumePluginDir = fmt.Sprintf("/%s", c.RandString()) + obj.CSRSigningController.ClusterSigningCertFile = fmt.Sprintf("/%s", c.String(0)) + obj.CSRSigningController.ClusterSigningKeyFile = fmt.Sprintf("/%s", c.String(0)) + obj.PersistentVolumeBinderController.VolumeConfiguration.FlexVolumePluginDir = fmt.Sprintf("/%s", c.String(0)) obj.TTLAfterFinishedController.ConcurrentTTLSyncs = c.Int31() }, } diff --git a/pkg/kubelet/apis/config/fuzzer/fuzzer.go b/pkg/kubelet/apis/config/fuzzer/fuzzer.go index 70d6d485c6c..fc6dc614036 100644 --- a/pkg/kubelet/apis/config/fuzzer/fuzzer.go +++ b/pkg/kubelet/apis/config/fuzzer/fuzzer.go @@ -20,7 +20,7 @@ import ( "math/rand" "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" @@ -38,8 +38,8 @@ import ( func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ // provide non-empty values for fields with defaults, so the defaulter doesn't change values during round-trip - func(obj *kubeletconfig.KubeletConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *kubeletconfig.KubeletConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) obj.EnableServer = true obj.Authentication.Anonymous.Enabled = true obj.Authentication.Webhook.Enabled = false diff --git a/pkg/kubelet/server/stats/summary_test.go b/pkg/kubelet/server/stats/summary_test.go index 938a6354bb7..81286856ea1 100644 --- a/pkg/kubelet/server/stats/summary_test.go +++ b/pkg/kubelet/server/stats/summary_test.go @@ -24,8 +24,8 @@ import ( "testing" "time" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" + "sigs.k8s.io/randfill" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -313,45 +313,45 @@ func TestSummaryProviderGetCPUAndMemoryStats(t *testing.T) { } func getFsStats() *statsapi.FsStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.FsStats{} - f.Fuzz(v) + f.Fill(v) return v } func getContainerStats() *statsapi.ContainerStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.ContainerStats{} - f.Fuzz(v) + f.Fill(v) return v } func getVolumeCPUAndMemoryStats() *statsapi.ContainerStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.ContainerStats{} - f.Fuzz(&v.Name) - f.Fuzz(&v.StartTime) - f.Fuzz(v.CPU) - f.Fuzz(v.Memory) + f.Fill(&v.Name) + f.Fill(&v.StartTime) + f.Fill(v.CPU) + f.Fill(v.Memory) return v } func getVolumeStats() *statsapi.VolumeStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.VolumeStats{} - f.Fuzz(v) + f.Fill(v) return v } func getNetworkStats() *statsapi.NetworkStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.NetworkStats{} - f.Fuzz(v) + f.Fill(v) return v } func getRlimitStats() *statsapi.RlimitStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.RlimitStats{} - f.Fuzz(v) + f.Fill(v) return v } diff --git a/pkg/kubelet/server/stats/summary_windows_test.go b/pkg/kubelet/server/stats/summary_windows_test.go index 21f46d2654f..db88528b5ca 100644 --- a/pkg/kubelet/server/stats/summary_windows_test.go +++ b/pkg/kubelet/server/stats/summary_windows_test.go @@ -24,8 +24,8 @@ import ( "testing" "time" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" + "sigs.k8s.io/randfill" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -95,16 +95,16 @@ func TestSummaryProvider(t *testing.T) { } func getFsStats() *statsapi.FsStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.FsStats{} - f.Fuzz(v) + f.Fill(v) return v } func getContainerStats() *statsapi.ContainerStats { - f := fuzz.New().NilChance(0) + f := randfill.New().NilChance(0) v := &statsapi.ContainerStats{} - f.Fuzz(v) + f.Fill(v) return v } diff --git a/pkg/kubelet/stats/provider_test.go b/pkg/kubelet/stats/provider_test.go index c58830ff5ef..0d52a1c468b 100644 --- a/pkg/kubelet/stats/provider_test.go +++ b/pkg/kubelet/stats/provider_test.go @@ -26,9 +26,9 @@ import ( cadvisorapiv1 "github.com/google/cadvisor/info/v1" cadvisorapiv2 "github.com/google/cadvisor/info/v2" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -389,9 +389,9 @@ func getPodVolumeStats(seed int, volumeName string) statsapi.VolumeStats { } func generateCustomMetricSpec() []cadvisorapiv1.MetricSpec { - f := fuzz.New().NilChance(0).Funcs( - func(e *cadvisorapiv1.MetricSpec, c fuzz.Continue) { - c.Fuzz(&e.Name) + f := randfill.New().NilChance(0).Funcs( + func(e *cadvisorapiv1.MetricSpec, c randfill.Continue) { + c.Fill(&e.Name) switch c.Intn(3) { case 0: e.Type = cadvisorapiv1.MetricGauge @@ -406,28 +406,28 @@ func generateCustomMetricSpec() []cadvisorapiv1.MetricSpec { case 1: e.Format = cadvisorapiv1.FloatType } - c.Fuzz(&e.Units) + c.Fill(&e.Units) }) var ret []cadvisorapiv1.MetricSpec - f.Fuzz(&ret) + f.Fill(&ret) return ret } func generateCustomMetrics(spec []cadvisorapiv1.MetricSpec) map[string][]cadvisorapiv1.MetricVal { ret := map[string][]cadvisorapiv1.MetricVal{} for _, metricSpec := range spec { - f := fuzz.New().NilChance(0).Funcs( - func(e *cadvisorapiv1.MetricVal, c fuzz.Continue) { + f := randfill.New().NilChance(0).Funcs( + func(e *cadvisorapiv1.MetricVal, c randfill.Continue) { switch metricSpec.Format { case cadvisorapiv1.IntType: - c.Fuzz(&e.IntValue) + c.Fill(&e.IntValue) case cadvisorapiv1.FloatType: - c.Fuzz(&e.FloatValue) + c.Fill(&e.FloatValue) } }) var metrics []cadvisorapiv1.MetricVal - f.Fuzz(&metrics) + f.Fill(&metrics) ret[metricSpec.Name] = metrics } return ret diff --git a/pkg/proxy/apis/config/fuzzer/fuzzer.go b/pkg/proxy/apis/config/fuzzer/fuzzer.go index c835dce440f..8ad2064d575 100644 --- a/pkg/proxy/apis/config/fuzzer/fuzzer.go +++ b/pkg/proxy/apis/config/fuzzer/fuzzer.go @@ -21,7 +21,7 @@ import ( "net/netip" "time" - "github.com/google/gofuzz" + "sigs.k8s.io/randfill" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" @@ -30,7 +30,7 @@ import ( ) // generateRandomIP is copied from pkg/apis/networking/fuzzer/fuzzer.go -func generateRandomIP(is6 bool, c fuzz.Continue) string { +func generateRandomIP(is6 bool, c randfill.Continue) string { n := 4 if is6 { n = 16 @@ -49,7 +49,7 @@ func generateRandomIP(is6 bool, c fuzz.Continue) string { } // generateRandomCIDR is copied from pkg/apis/networking/fuzzer/fuzzer.go -func generateRandomCIDR(is6 bool, c fuzz.Continue) string { +func generateRandomCIDR(is6 bool, c randfill.Continue) string { ip, err := netip.ParseAddr(generateRandomIP(is6, c)) if err != nil { // generateRandomIP already panics if returns a not valid ip @@ -67,12 +67,12 @@ func generateRandomCIDR(is6 bool, c fuzz.Continue) string { } // getRandomDualStackCIDR returns a random dual-stack CIDR. -func getRandomDualStackCIDR(c fuzz.Continue) []string { +func getRandomDualStackCIDR(c randfill.Continue) []string { cidrIPv4 := generateRandomCIDR(false, c) cidrIPv6 := generateRandomCIDR(true, c) cidrs := []string{cidrIPv4, cidrIPv6} - if c.RandBool() { + if c.Bool() { cidrs = []string{cidrIPv6, cidrIPv4} } return cidrs[:1+c.Intn(2)] @@ -81,19 +81,19 @@ func getRandomDualStackCIDR(c fuzz.Continue) []string { // Funcs returns the fuzzer functions for the kube-proxy apis. func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *kubeproxyconfig.KubeProxyConfiguration, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *kubeproxyconfig.KubeProxyConfiguration, c randfill.Continue) { + c.FillNoCustom(obj) obj.BindAddress = fmt.Sprintf("%d.%d.%d.%d", c.Intn(256), c.Intn(256), c.Intn(256), c.Intn(256)) - obj.ClientConnection.ContentType = c.RandString() + obj.ClientConnection.ContentType = c.String(0) obj.DetectLocal.ClusterCIDRs = getRandomDualStackCIDR(c) obj.Linux.Conntrack.MaxPerCore = ptr.To(c.Int31()) obj.Linux.Conntrack.Min = ptr.To(c.Int31()) obj.Linux.Conntrack.TCPCloseWaitTimeout = &metav1.Duration{Duration: time.Duration(c.Int63()) * time.Hour} obj.Linux.Conntrack.TCPEstablishedTimeout = &metav1.Duration{Duration: time.Duration(c.Int63()) * time.Hour} - obj.FeatureGates = map[string]bool{c.RandString(): true} + obj.FeatureGates = map[string]bool{c.String(0): true} obj.HealthzBindAddress = fmt.Sprintf("%d.%d.%d.%d:%d", c.Intn(256), c.Intn(256), c.Intn(256), c.Intn(256), c.Intn(65536)) obj.IPTables.MasqueradeBit = ptr.To(c.Int31()) - obj.IPTables.LocalhostNodePorts = ptr.To(c.RandBool()) + obj.IPTables.LocalhostNodePorts = ptr.To(c.Bool()) obj.NFTables.MasqueradeBit = ptr.To(c.Int31()) obj.MetricsBindAddress = fmt.Sprintf("%d.%d.%d.%d:%d", c.Intn(256), c.Intn(256), c.Intn(256), c.Intn(256), c.Intn(65536)) obj.Linux.OOMScoreAdj = ptr.To(c.Int31()) diff --git a/pkg/registry/rbac/helpers_test.go b/pkg/registry/rbac/helpers_test.go index 765ca3fea04..cc340b4147b 100644 --- a/pkg/registry/rbac/helpers_test.go +++ b/pkg/registry/rbac/helpers_test.go @@ -26,7 +26,7 @@ import ( kapi "k8s.io/kubernetes/pkg/apis/core" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func newPod() *kapi.Pod { @@ -172,10 +172,10 @@ func TestIsOnlyMutatingGCFields(t *testing.T) { } func TestNewMetadataFields(t *testing.T) { - f := fuzz.New().NilChance(0.0).NumElements(1, 1) + f := randfill.New().NilChance(0.0).NumElements(1, 1) for i := 0; i < 100; i++ { objMeta := metav1.ObjectMeta{} - f.Fuzz(&objMeta) + f.Fill(&objMeta) objMeta.Name = "" objMeta.GenerateName = "" objMeta.Namespace = "" diff --git a/staging/src/k8s.io/api/go.mod b/staging/src/k8s.io/api/go.mod index fae49b9ded3..43d1e6aac26 100644 --- a/staging/src/k8s.io/api/go.mod +++ b/staging/src/k8s.io/api/go.mod @@ -16,7 +16,6 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -30,7 +29,8 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/api/go.sum b/staging/src/k8s.io/api/go.sum index c518de7ccac..3ac3c91d5df 100644 --- a/staging/src/k8s.io/api/go.sum +++ b/staging/src/k8s.io/api/go.sum @@ -17,8 +17,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -106,12 +104,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.mod b/staging/src/k8s.io/apiextensions-apiserver/go.mod index db2918df49b..9e21480d042 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.mod +++ b/staging/src/k8s.io/apiextensions-apiserver/go.mod @@ -13,7 +13,6 @@ require ( github.com/google/cel-go v0.23.2 github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.6.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 @@ -32,10 +31,11 @@ require ( k8s.io/code-generator v0.0.0 k8s.io/component-base v0.0.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 sigs.k8s.io/yaml v1.4.0 ) diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.sum b/staging/src/k8s.io/apiextensions-apiserver/go.sum index 0adb2790cea..c0f12cdbe45 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.sum +++ b/staging/src/k8s.io/apiextensions-apiserver/go.sum @@ -219,8 +219,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -512,15 +510,18 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go index 9823b3e8d6c..4029c823e35 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go @@ -20,7 +20,7 @@ import ( "reflect" "strings" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -33,8 +33,8 @@ var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc() // Funcs returns the fuzzer functions for the apiextensions apis. func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(obj *apiextensions.CustomResourceDefinitionSpec, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *apiextensions.CustomResourceDefinitionSpec, c randfill.Continue) { + c.FillNoCustom(obj) // match our defaulter if len(obj.Scope) == 0 { @@ -66,7 +66,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { {Name: "Age", Type: "date", Description: swaggerMetadataDescriptions["creationTimestamp"], JSONPath: ".metadata.creationTimestamp"}, } } - c.Fuzz(&obj.SelectableFields) + c.Fill(&obj.SelectableFields) if obj.Conversion == nil { obj.Conversion = &apiextensions.CustomResourceConversion{ Strategy: apiextensions.NoneConverter, @@ -100,8 +100,8 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(obj *apiextensions.CustomResourceDefinition, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *apiextensions.CustomResourceDefinition, c randfill.Continue) { + c.FillNoCustom(obj) if len(obj.Status.StoredVersions) == 0 { for _, v := range obj.Spec.Versions { @@ -111,7 +111,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(obj *apiextensions.JSONSchemaProps, c fuzz.Continue) { + func(obj *apiextensions.JSONSchemaProps, c randfill.Continue) { // we cannot use c.FuzzNoCustom because of the interface{} fields. So let's loop with reflection. vobj := reflect.ValueOf(obj).Elem() tobj := reflect.TypeOf(obj).Elem() @@ -127,22 +127,22 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { isValue = false } if isValue || c.Intn(10) == 0 { - c.Fuzz(vobj.Field(i).Addr().Interface()) + c.Fill(vobj.Field(i).Addr().Interface()) } } } - if c.RandBool() { + if c.Bool() { validJSON := apiextensions.JSON(`{"some": {"json": "test"}, "string": 42}`) obj.Default = &validJSON } - if c.RandBool() { - obj.Enum = []apiextensions.JSON{c.Float64(), c.RandString(), c.RandBool()} + if c.Bool() { + obj.Enum = []apiextensions.JSON{c.Float64(), c.String(0), c.Bool()} } - if c.RandBool() { + if c.Bool() { validJSON := apiextensions.JSON(`"foobarbaz"`) obj.Example = &validJSON } - if c.RandBool() { + if c.Bool() { validRef := "validRef" obj.Ref = &validRef } @@ -153,41 +153,41 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { obj.Type = "" } }, - func(obj *apiextensions.JSONSchemaPropsOrBool, c fuzz.Continue) { - if c.RandBool() { + func(obj *apiextensions.JSONSchemaPropsOrBool, c randfill.Continue) { + if c.Bool() { obj.Allows = true obj.Schema = &apiextensions.JSONSchemaProps{} - c.Fuzz(obj.Schema) + c.Fill(obj.Schema) } else { - obj.Allows = c.RandBool() + obj.Allows = c.Bool() } }, - func(obj *apiextensions.JSONSchemaPropsOrArray, c fuzz.Continue) { + func(obj *apiextensions.JSONSchemaPropsOrArray, c randfill.Continue) { // disallow both Schema and JSONSchemas to be nil. - if c.RandBool() { + if c.Bool() { obj.Schema = &apiextensions.JSONSchemaProps{} - c.Fuzz(obj.Schema) + c.Fill(obj.Schema) } else { obj.JSONSchemas = make([]apiextensions.JSONSchemaProps, c.Intn(3)+1) for i := range obj.JSONSchemas { - c.Fuzz(&obj.JSONSchemas[i]) + c.Fill(&obj.JSONSchemas[i]) } } }, - func(obj *apiextensions.JSONSchemaPropsOrStringArray, c fuzz.Continue) { - if c.RandBool() { + func(obj *apiextensions.JSONSchemaPropsOrStringArray, c randfill.Continue) { + if c.Bool() { obj.Schema = &apiextensions.JSONSchemaProps{} - c.Fuzz(obj.Schema) + c.Fill(obj.Schema) } else { - c.Fuzz(&obj.Property) + c.Fill(&obj.Property) } }, - func(obj *int64, c fuzz.Continue) { + func(obj *int64, c randfill.Continue) { // JSON only supports 53 bits because everything is a float *obj = int64(c.Uint64()) & ((int64(1) << 53) - 1) }, - func(obj *apiextensions.ValidationRule, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *apiextensions.ValidationRule, c randfill.Continue) { + c.FillNoCustom(obj) if obj.Reason != nil && *(obj.Reason) == "" { obj.Reason = nil } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go index dcc10ad79f8..7662a613069 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go @@ -10948,7 +10948,7 @@ func TestSchemaHasDefaults(t *testing.T) { for i := 0; i < 10000; i++ { // fuzz internal types schema := &apiextensions.JSONSchemaProps{} - f.Fuzz(schema) + f.Fill(schema) v1beta1Schema := &apiextensionsv1beta1.JSONSchemaProps{} if err := apiextensionsv1beta1.Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(schema, v1beta1Schema, nil); err != nil { @@ -11072,7 +11072,7 @@ func BenchmarkSchemaHas(b *testing.B) { f := fuzzer.FuzzerFor(fuzzerFuncs, rand.NewSource(seed), codecs) // fuzz internal types schema := &apiextensions.JSONSchemaProps{} - f.NilChance(0).NumElements(10, 10).MaxDepth(10).Fuzz(schema) + f.NilChance(0).NumElements(10, 10).MaxDepth(10).Fill(schema) b.ReportAllocs() b.ResetTimer() diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/roundtrip_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/roundtrip_test.go index b0ab41f9717..b7ba261f9ba 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/roundtrip_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/roundtrip_test.go @@ -21,8 +21,8 @@ import ( "strconv" "testing" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" apiextensionsfuzzer "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install" @@ -81,8 +81,8 @@ func TestRoundtripToUnstructured(t *testing.T) { apiextensionsfuzzer.Funcs, func(_ serializer.CodecFactory) []any { return []any{ - func(obj *apiextensionsv1.ConversionReview, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *apiextensionsv1.ConversionReview, c randfill.Continue) { + c.FillNoCustom(obj) if obj.Request != nil { for i := range obj.Request.Objects { fuzzer.NormalizeJSONRawExtension(&obj.Request.Objects[i]) @@ -94,8 +94,8 @@ func TestRoundtripToUnstructured(t *testing.T) { } } }, - func(obj *apiextensionsv1beta1.ConversionReview, c fuzz.Continue) { - c.FuzzNoCustom(obj) + func(obj *apiextensionsv1beta1.ConversionReview, c randfill.Continue) { + c.FillNoCustom(obj) if obj.Request != nil { for i := range obj.Request.Objects { fuzzer.NormalizeJSONRawExtension(&obj.Request.Objects[i]) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/convert_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/convert_test.go index 66b89b01142..5eb7fba2727 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/convert_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/convert_test.go @@ -23,7 +23,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -31,31 +31,31 @@ import ( ) func TestStructuralRoundtripOrError(t *testing.T) { - f := fuzz.New() + f := randfill.New() seed := time.Now().UnixNano() t.Logf("seed = %v", seed) //seed = int64(1549012506261785182) f.RandSource(rand.New(rand.NewSource(seed))) f.Funcs( - func(s *apiextensions.JSON, c fuzz.Continue) { + func(s *apiextensions.JSON, c randfill.Continue) { *s = apiextensions.JSON(map[string]interface{}{"foo": float64(42.2)}) }, - func(s *apiextensions.JSONSchemaPropsOrArray, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *apiextensions.JSONSchemaPropsOrArray, c randfill.Continue) { + c.FillNoCustom(s) if s.Schema != nil { s.JSONSchemas = nil } else if s.JSONSchemas == nil { s.Schema = &apiextensions.JSONSchemaProps{} } }, - func(s *apiextensions.JSONSchemaPropsOrBool, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *apiextensions.JSONSchemaPropsOrBool, c randfill.Continue) { + c.FillNoCustom(s) if s.Schema != nil { s.Allows = false } }, - func(s **string, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s **string, c randfill.Continue) { + c.FillNoCustom(s) if *s != nil && **s == "" { *s = nil } @@ -74,7 +74,7 @@ func TestStructuralRoundtripOrError(t *testing.T) { // we drop these intentionally continue } - f.Fuzz(x.Field(n).Addr().Interface()) + f.Fill(x.Field(n).Addr().Interface()) // it roundtrips or NewStructural errors out. We should never drop anything orig, err := NewStructural(origSchema) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go index fef89bb8f5e..b327e52d561 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/kubeopenapi_test.go @@ -23,7 +23,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -31,13 +31,13 @@ import ( ) func TestStructuralKubeOpenAPIRoundtrip(t *testing.T) { - f := fuzz.New() + f := randfill.New() seed := time.Now().UnixNano() t.Logf("seed = %v", seed) //seed = int64(1549012506261785182) f.RandSource(rand.New(rand.NewSource(seed))) f.Funcs( - func(s *JSON, c fuzz.Continue) { + func(s *JSON, c randfill.Continue) { switch c.Intn(7) { case 0: s.Object = float64(42.2) @@ -61,7 +61,7 @@ func TestStructuralKubeOpenAPIRoundtrip(t *testing.T) { for i := 0; i < 10000; i++ { orig := &Structural{} - f.Fuzz(orig) + f.Fill(orig) // normalize Structural.ValueValidation to zero values if it was nil before normalizer := Visitor{ diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/objectmeta/coerce_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/objectmeta/coerce_test.go index d52e18fe3f7..620983e06ac 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/objectmeta/coerce_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/objectmeta/coerce_test.go @@ -46,7 +46,7 @@ func TestRoundtripObjectMeta(t *testing.T) { for i := 0; i < N; i++ { u := &unstructured.Unstructured{Object: map[string]interface{}{}} original := &metav1.ObjectMeta{} - fuzzer.Fuzz(original) + fuzzer.Fill(original) if err := SetObjectMeta(u.Object, original); err != nil { t.Fatalf("unexpected error setting ObjectMeta: %v", err) } @@ -89,7 +89,7 @@ func TestMalformedObjectMetaFields(t *testing.T) { N := 100 for i := 0; i < N; i++ { fuzzedObjectMeta := &metav1.ObjectMeta{} - fuzzer.Fuzz(fuzzedObjectMeta) + fuzzer.Fill(fuzzedObjectMeta) goodMetaMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(fuzzedObjectMeta.DeepCopy()) if err != nil { t.Fatal(err) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/validation_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/validation_test.go index c7a3fdc8599..a83e50ff958 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/validation_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/validation_test.go @@ -24,39 +24,39 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func TestValidateStructuralMetadataInvariants(t *testing.T) { - fuzzer := fuzz.New() + fuzzer := randfill.New() fuzzer.Funcs( - func(s *JSON, c fuzz.Continue) { - if c.RandBool() { + func(s *JSON, c randfill.Continue) { + if c.Bool() { s.Object = float64(42.0) } }, - func(s **StructuralOrBool, c fuzz.Continue) { - if c.RandBool() { + func(s **StructuralOrBool, c randfill.Continue) { + if c.Bool() { *s = &StructuralOrBool{} } }, - func(s **Structural, c fuzz.Continue) { - if c.RandBool() { + func(s **Structural, c randfill.Continue) { + if c.Bool() { *s = &Structural{} } }, - func(s *Structural, c fuzz.Continue) { - if c.RandBool() { + func(s *Structural, c randfill.Continue) { + if c.Bool() { *s = Structural{} } }, - func(vv **NestedValueValidation, c fuzz.Continue) { - if c.RandBool() { + func(vv **NestedValueValidation, c randfill.Continue) { + if c.Bool() { *vv = &NestedValueValidation{} } }, - func(vv *NestedValueValidation, c fuzz.Continue) { - if c.RandBool() { + func(vv *NestedValueValidation, c randfill.Continue) { + if c.Bool() { *vv = NestedValueValidation{} } }, @@ -114,7 +114,7 @@ func TestValidateStructuralMetadataInvariants(t *testing.T) { for i := 0; i < tt.NumField(); i++ { s := Structural{} x := reflect.ValueOf(&s).Elem() - fuzzer.Fuzz(x.Field(i).Addr().Interface()) + fuzzer.Fill(x.Field(i).Addr().Interface()) s.Type = "object" s.Properties = map[string]Structural{ "name": {}, @@ -384,15 +384,15 @@ func TestValidateStructuralCompleteness(t *testing.T) { } func TestValidateNestedValueValidationComplete(t *testing.T) { - fuzzer := fuzz.New() + fuzzer := randfill.New() fuzzer.Funcs( - func(s *JSON, c fuzz.Continue) { - if c.RandBool() { + func(s *JSON, c randfill.Continue) { + if c.Bool() { s.Object = float64(42.0) } }, - func(s **NestedValueValidation, c fuzz.Continue) { - if c.RandBool() { + func(s **NestedValueValidation, c randfill.Continue) { + if c.Bool() { *s = &NestedValueValidation{} } }, @@ -404,7 +404,7 @@ func TestValidateNestedValueValidationComplete(t *testing.T) { for i := 0; i < tt.NumField(); i++ { vv := &NestedValueValidation{} x := reflect.ValueOf(&vv.ForbiddenGenerics).Elem() - fuzzer.Fuzz(x.Field(i).Addr().Interface()) + fuzzer.Fill(x.Field(i).Addr().Interface()) errs := validateNestedValueValidation(vv, false, false, fieldLevel, nil, ValidationOptions{}) if len(errs) == 0 && !reflect.DeepEqual(vv.ForbiddenGenerics, Generic{}) { @@ -417,7 +417,7 @@ func TestValidateNestedValueValidationComplete(t *testing.T) { for i := 0; i < tt.NumField(); i++ { vv := &NestedValueValidation{} x := reflect.ValueOf(&vv.ForbiddenExtensions).Elem() - fuzzer.Fuzz(x.Field(i).Addr().Interface()) + fuzzer.Fill(x.Field(i).Addr().Interface()) errs := validateNestedValueValidation(vv, false, false, fieldLevel, nil, ValidationOptions{}) if len(errs) == 0 && !reflect.DeepEqual(vv.ForbiddenExtensions, Extensions{}) { @@ -433,7 +433,7 @@ func TestValidateNestedValueValidationComplete(t *testing.T) { } vv := NestedValueValidation{} - fuzzer.Fuzz(&vv.ValidationExtensions.XValidations) + fuzzer.Fill(&vv.ValidationExtensions.XValidations) errs := validateNestedValueValidation(&vv, false, false, fieldLevel, nil, opts) if allowedNestedXValidations { if len(errs) != 0 { @@ -444,7 +444,7 @@ func TestValidateNestedValueValidationComplete(t *testing.T) { } vv = NestedValueValidation{} - fuzzer.Fuzz(&vv.AdditionalProperties) + fuzzer.Fill(&vv.AdditionalProperties) errs = validateNestedValueValidation(&vv, false, false, fieldLevel, nil, opts) if allowedNestedAdditionalProperties { if len(errs) != 0 { diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go index 27a10f4dc05..20fa9d761c2 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go @@ -76,7 +76,7 @@ func TestRoundTrip(t *testing.T) { for i := 0; i < 50; i++ { // fuzz internal types internal := &apiextensions.JSONSchemaProps{} - f.Fuzz(internal) + f.Fill(internal) // internal -> go-openapi openAPITypes := &kubeopenapispec.Schema{} diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/v2/conversion_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/v2/conversion_test.go index e7eb064ef5b..bd0e71e9f8f 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/v2/conversion_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/v2/conversion_test.go @@ -27,7 +27,7 @@ import ( openapi_v2 "github.com/google/gnostic-models/openapiv2" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -704,15 +704,15 @@ func refEqual(x spec.Ref, y spec.Ref) bool { func TestKubeOpenapiRejectionFiltering(t *testing.T) { // 1000 iterations runs for ~2 seconds with race detection enabled for i := 0; i < 1000; i++ { - f := fuzz.New() + f := randfill.New() seed := time.Now().UnixNano() randSource := rand.New(rand.NewSource(seed)) f.RandSource(randSource) t.Logf("iteration %d with seed %d", i, seed) - fuzzFuncs(f, func(ref *spec.Ref, c fuzz.Continue, visible bool) { + fuzzFuncs(f, func(ref *spec.Ref, c randfill.Continue, visible bool) { var url string - if c.RandBool() { + if c.Bool() { url = fmt.Sprintf("http://%d", c.Intn(100000)) } else { url = "#/definitions/test" @@ -726,7 +726,7 @@ func TestKubeOpenapiRejectionFiltering(t *testing.T) { // create go-openapi object and fuzz it (we start here because we have the powerful fuzzer already s := &spec.Schema{} - f.Fuzz(s) + f.Fill(s) // convert to apiextensions v1beta1 bs, err := json.Marshal(s) @@ -790,7 +790,7 @@ func TestKubeOpenapiRejectionFiltering(t *testing.T) { } // fuzzFuncs is copied from kube-openapi/pkg/aggregator. It fuzzes go-openapi/spec schemata. -func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visible bool)) { +func fuzzFuncs(f *randfill.Filler, refFunc func(ref *spec.Ref, c randfill.Continue, visible bool)) { invisible := 0 // == 0 means visible, > 0 means invisible depth := 0 maxDepth := 3 @@ -802,14 +802,14 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi f.NumElements(0, max(0, maxDepth-depth)) } updateFuzzer(depth) - enter := func(o interface{}, recursive bool, c fuzz.Continue) { + enter := func(o interface{}, recursive bool, c randfill.Continue) { if recursive { depth++ updateFuzzer(depth) } invisible++ - c.FuzzNoCustom(o) + c.FillNoCustom(o) invisible-- } leave := func(recursive bool) { @@ -819,31 +819,31 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi } } f.Funcs( - func(ref *spec.Ref, c fuzz.Continue) { + func(ref *spec.Ref, c randfill.Continue) { refFunc(ref, c, invisible == 0) }, - func(sa *spec.SchemaOrStringArray, c fuzz.Continue) { + func(sa *spec.SchemaOrStringArray, c randfill.Continue) { *sa = spec.SchemaOrStringArray{} - if c.RandBool() { - c.Fuzz(&sa.Schema) + if c.Bool() { + c.Fill(&sa.Schema) } else { - c.Fuzz(&sa.Property) + c.Fill(&sa.Property) } if sa.Schema == nil && len(sa.Property) == 0 { *sa = spec.SchemaOrStringArray{Schema: &spec.Schema{}} } }, - func(url *spec.SchemaURL, c fuzz.Continue) { + func(url *spec.SchemaURL, c randfill.Continue) { *url = spec.SchemaURL("http://url") }, - func(s *spec.Dependencies, c fuzz.Continue) { + func(s *spec.Dependencies, c randfill.Continue) { enter(s, false, c) defer leave(false) // and nothing with invisible==false }, - func(p *spec.SimpleSchema, c fuzz.Continue) { - // gofuzz is broken and calls this even for *SimpleSchema fields, ignoring NilChance, leading to infinite recursion + func(p *spec.SimpleSchema, c randfill.Continue) { + // randfill is broken and calls this even for *SimpleSchema fields, ignoring NilChance, leading to infinite recursion if c.Float64() > nilChance(depth) { return } @@ -851,7 +851,7 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi enter(p, true, c) defer leave(true) - c.FuzzNoCustom(p) + c.FillNoCustom(p) // reset JSON fields to some correct JSON if p.Default != nil { @@ -859,12 +859,12 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi } p.Example = nil }, - func(s *spec.SwaggerSchemaProps, c fuzz.Continue) { + func(s *spec.SwaggerSchemaProps, c randfill.Continue) { // nothing allowed *s = spec.SwaggerSchemaProps{} }, - func(s *spec.SchemaProps, c fuzz.Continue) { - // gofuzz is broken and calls this even for *SchemaProps fields, ignoring NilChance, leading to infinite recursion + func(s *spec.SchemaProps, c randfill.Continue) { + // randfill is broken and calls this even for *SchemaProps fields, ignoring NilChance, leading to infinite recursion if c.Float64() > nilChance(depth) { return } @@ -872,9 +872,9 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi enter(s, true, c) defer leave(true) - c.FuzzNoCustom(s) + c.FillNoCustom(s) - if c.RandBool() { + if c.Bool() { types := []string{"object", "array", "boolean", "string", "integer", "number"} s.Type = []string{types[c.Intn(len(types))]} } else { @@ -891,7 +891,7 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi if len(s.Type) == 1 && s.Type[0] == "array" { s.Items = &spec.SchemaOrArray{Schema: &spec.Schema{}} - c.Fuzz(s.Items.Schema) + c.Fill(s.Items.Schema) } else { s.Items = nil } @@ -904,7 +904,7 @@ func fuzzFuncs(f *fuzz.Fuzzer, refFunc func(ref *spec.Ref, c fuzz.Continue, visi s.Enum[i] = "42" } }, - func(i *interface{}, c fuzz.Continue) { + func(i *interface{}, c randfill.Continue) { // do nothing for examples and defaults. These are free form JSON fields. }, ) diff --git a/staging/src/k8s.io/apimachinery/go.mod b/staging/src/k8s.io/apimachinery/go.mod index df1e41c21dc..c5395186fab 100644 --- a/staging/src/k8s.io/apimachinery/go.mod +++ b/staging/src/k8s.io/apimachinery/go.mod @@ -13,7 +13,6 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.6.0 github.com/moby/spdystream v0.5.0 github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f @@ -24,10 +23,11 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 gopkg.in/inf.v0 v0.9.1 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 sigs.k8s.io/yaml v1.4.0 ) diff --git a/staging/src/k8s.io/apimachinery/go.sum b/staging/src/k8s.io/apimachinery/go.sum index a2222451422..3179f3619e5 100644 --- a/staging/src/k8s.io/apimachinery/go.sum +++ b/staging/src/k8s.io/apimachinery/go.sum @@ -29,8 +29,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -140,13 +138,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/fuzzer/fuzzer.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/fuzzer/fuzzer.go index f8539fa998a..a12370886fc 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/fuzzer/fuzzer.go @@ -21,19 +21,19 @@ import ( "fmt" "math/rand" - "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" kjson "k8s.io/apimachinery/pkg/util/json" ) -// FuzzerFuncs returns a list of func(*SomeType, c fuzz.Continue) functions. +// FuzzerFuncs returns a list of func(*SomeType, c randfill.Continue) functions. type FuzzerFuncs func(codecs runtimeserializer.CodecFactory) []interface{} // FuzzerFor can randomly populate api objects that are destined for version. -func FuzzerFor(funcs FuzzerFuncs, src rand.Source, codecs runtimeserializer.CodecFactory) *fuzz.Fuzzer { - f := fuzz.New().NilChance(.5).NumElements(0, 1) +func FuzzerFor(funcs FuzzerFuncs, src rand.Source, codecs runtimeserializer.CodecFactory) *randfill.Filler { + f := randfill.New().NilChance(.5).NumElements(0, 1) if src != nil { f.RandSource(src) } diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go index 2ebcf37e284..51f1a350f83 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go @@ -25,8 +25,8 @@ import ( "testing" "github.com/google/go-cmp/cmp" //nolint:depguard - fuzz "github.com/google/gofuzz" flag "github.com/spf13/pflag" + "sigs.k8s.io/randfill" apitesting "k8s.io/apimachinery/pkg/api/apitesting" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" @@ -120,15 +120,15 @@ func GlobalNonRoundTrippableTypes() sets.String { // RoundTripTypesWithoutProtobuf applies the round-trip test to all round-trippable Kinds // in the scheme. It will skip all the GroupVersionKinds in the skip list. -func RoundTripTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { +func RoundTripTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { roundTripTypes(t, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, true) } -func RoundTripTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { +func RoundTripTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { roundTripTypes(t, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, false) } -func roundTripTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool, skipProtobuf bool) { +func roundTripTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool, skipProtobuf bool) { for _, group := range groupsFromScheme(scheme) { t.Logf("starting group %q", group) internalVersion := schema.GroupVersion{Group: group, Version: runtime.APIVersionInternal} @@ -149,7 +149,7 @@ func roundTripTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimese // RoundTripExternalTypes applies the round-trip test to all external round-trippable Kinds // in the scheme. It will skip all the GroupVersionKinds in the nonRoundTripExternalTypes list . -func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { +func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { kinds := scheme.AllKnownTypes() for gvk := range kinds { if gvk.Version == runtime.APIVersionInternal || globalNonRoundTrippableTypes.Has(gvk.Kind) { @@ -163,7 +163,7 @@ func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory r // RoundTripExternalTypesWithoutProtobuf applies the round-trip test to all external round-trippable Kinds // in the scheme. It will skip all the GroupVersionKinds in the nonRoundTripExternalTypes list. -func RoundTripExternalTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { +func RoundTripExternalTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { kinds := scheme.AllKnownTypes() for gvk := range kinds { if gvk.Version == runtime.APIVersionInternal || globalNonRoundTrippableTypes.Has(gvk.Kind) { @@ -175,15 +175,15 @@ func RoundTripExternalTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, } } -func RoundTripSpecificKindWithoutProtobuf(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { +func RoundTripSpecificKindWithoutProtobuf(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { roundTripSpecificKind(t, gvk, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, true) } -func RoundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { +func RoundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool) { roundTripSpecificKind(t, gvk, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, false) } -func roundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool, skipProtobuf bool) { +func roundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, nonRoundTrippableTypes map[schema.GroupVersionKind]bool, skipProtobuf bool) { if nonRoundTrippableTypes[gvk] { t.Logf("skipping %v", gvk) return @@ -204,8 +204,8 @@ func roundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *ru // fuzzInternalObject fuzzes an arbitrary runtime object using the appropriate // fuzzer registered with the apitesting package. -func fuzzInternalObject(t *testing.T, fuzzer *fuzz.Fuzzer, object runtime.Object) runtime.Object { - fuzzer.Fuzz(object) +func fuzzInternalObject(t *testing.T, fuzzer *randfill.Filler, object runtime.Object) runtime.Object { + fuzzer.Fill(object) j, err := apimeta.TypeAccessor(object) if err != nil { @@ -225,7 +225,7 @@ func groupsFromScheme(scheme *runtime.Scheme) []string { return ret.List() } -func roundTripToAllExternalVersions(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, internalGVK schema.GroupVersionKind, nonRoundTrippableTypes map[schema.GroupVersionKind]bool, skipProtobuf bool) { +func roundTripToAllExternalVersions(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, internalGVK schema.GroupVersionKind, nonRoundTrippableTypes map[schema.GroupVersionKind]bool, skipProtobuf bool) { object, err := scheme.New(internalGVK) if err != nil { t.Fatalf("Couldn't make a %v? %v", internalGVK, err) @@ -262,7 +262,7 @@ func roundTripToAllExternalVersions(t *testing.T, scheme *runtime.Scheme, codecF } } -func roundTripOfExternalType(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, externalGVK schema.GroupVersionKind, skipProtobuf bool) { +func roundTripOfExternalType(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *randfill.Filler, externalGVK schema.GroupVersionKind, skipProtobuf bool) { object, err := scheme.New(externalGVK) if err != nil { t.Fatalf("Couldn't make a %v? %v", externalGVK, err) diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/unstructured.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/unstructured.go index d45ba26687a..d5ab664d31d 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/unstructured.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/unstructured.go @@ -92,13 +92,13 @@ func RoundtripToUnstructured(t *testing.T, scheme *runtime.Scheme, funcs fuzzer. } if nointernal.Has(gvk) { - fuzzer.Fuzz(item) + fuzzer.Fill(item) } else { internalObj, err := scheme.New(gvk.GroupKind().WithVersion(runtime.APIVersionInternal)) if err != nil { t.Fatalf("couldn't create internal object %v: %v", gvk.Kind, err) } - fuzzer.Fuzz(internalObj) + fuzzer.Fill(internalObj) if err := scheme.Convert(internalObj, item, nil); err != nil { t.Fatalf("conversion for %v failed: %v", gvk.Kind, err) diff --git a/staging/src/k8s.io/apimachinery/pkg/api/meta/meta_test.go b/staging/src/k8s.io/apimachinery/pkg/api/meta/meta_test.go index f3cf634f4df..31402441a9e 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/meta/meta_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/meta/meta_test.go @@ -25,15 +25,15 @@ import ( metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func TestAsPartialObjectMetadata(t *testing.T) { - f := fuzz.New().NilChance(.5).NumElements(0, 1).RandSource(rand.NewSource(1)) + f := randfill.New().NilChance(.5).NumElements(0, 1).RandSource(rand.NewSource(1)) for i := 0; i < 100; i++ { m := &metav1.ObjectMeta{} - f.Fuzz(m) + f.Fill(m) partial := AsPartialObjectMetadata(m) if !reflect.DeepEqual(&partial.ObjectMeta, m) { t.Fatalf("incomplete partial object metadata: %s", cmp.Diff(&partial.ObjectMeta, m)) @@ -42,7 +42,7 @@ func TestAsPartialObjectMetadata(t *testing.T) { for i := 0; i < 100; i++ { m := &metav1beta1.PartialObjectMetadata{} - f.Fuzz(&m.ObjectMeta) + f.Fill(&m.ObjectMeta) partial := AsPartialObjectMetadata(m) if !reflect.DeepEqual(&partial.ObjectMeta, &m.ObjectMeta) { t.Fatalf("incomplete partial object metadata: %s", cmp.Diff(&partial.ObjectMeta, &m.ObjectMeta)) diff --git a/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity_test.go b/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity_test.go index 79d7f30b92a..59cc248510e 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity_test.go @@ -28,9 +28,9 @@ import ( "unicode" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "github.com/spf13/pflag" inf "gopkg.in/inf.v0" + "sigs.k8s.io/randfill" cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct" ) @@ -827,12 +827,12 @@ func TestQuantityParseEmit(t *testing.T) { } } -var fuzzer = fuzz.New().Funcs( - func(q *Quantity, c fuzz.Continue) { +var fuzzer = randfill.New().Funcs( + func(q *Quantity, c randfill.Continue) { q.i = Zero - if c.RandBool() { + if c.Bool() { q.Format = BinarySI - if c.RandBool() { + if c.Bool() { dec := &inf.Dec{} q.d = infDecAmount{Dec: dec} dec.SetScale(0) @@ -846,12 +846,12 @@ var fuzzer = fuzz.New().Funcs( dec.SetUnscaled(c.Int63n(1024) << uint(10*c.Intn(5))) return } - if c.RandBool() { + if c.Bool() { q.Format = DecimalSI } else { q.Format = DecimalExponent } - if c.RandBool() { + if c.Bool() { dec := &inf.Dec{} q.d = infDecAmount{Dec: dec} dec.SetScale(inf.Scale(c.Intn(4))) @@ -897,7 +897,7 @@ func TestQuantityDeepCopy(t *testing.T) { func TestJSON(t *testing.T) { for i := 0; i < 500; i++ { q := &Quantity{} - fuzzer.Fuzz(q) + fuzzer.Fill(q) b, err := json.Marshal(q) if err != nil { t.Errorf("error encoding %v: %v", q, err) @@ -1801,7 +1801,7 @@ func TestQuantityUnmarshalCBOR(t *testing.T) { func TestQuantityRoundtripCBOR(t *testing.T) { for i := 0; i < 500; i++ { var initial, final Quantity - fuzzer.Fuzz(&initial) + fuzzer.Fill(&initial) b, err := cbor.Marshal(initial) if err != nil { t.Errorf("error encoding %v: %v", initial, err) diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/fuzzer/fuzzer.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/fuzzer/fuzzer.go index b47f0c0ddb2..c263f1450dd 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/fuzzer/fuzzer.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" apitesting "k8s.io/apimachinery/pkg/api/apitesting" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" @@ -38,29 +38,29 @@ import ( func genericFuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(q *resource.Quantity, c fuzz.Continue) { + func(q *resource.Quantity, c randfill.Continue) { *q = *resource.NewQuantity(c.Int63n(1000), resource.DecimalExponent) }, - func(j *int, c fuzz.Continue) { + func(j *int, c randfill.Continue) { *j = int(c.Int31()) }, - func(j **int, c fuzz.Continue) { - if c.RandBool() { + func(j **int, c randfill.Continue) { + if c.Bool() { i := int(c.Int31()) *j = &i } else { *j = nil } }, - func(j *runtime.TypeMeta, c fuzz.Continue) { + func(j *runtime.TypeMeta, c randfill.Continue) { // We have to customize the randomization of TypeMetas because their // APIVersion and Kind must remain blank in memory. j.APIVersion = "" j.Kind = "" }, - func(j *runtime.Object, c fuzz.Continue) { + func(j *runtime.Object, c randfill.Continue) { // TODO: uncomment when round trip starts from a versioned object - if true { //c.RandBool() { + if true { // c.Bool() { *j = &runtime.Unknown{ // We do not set TypeMeta here because it is not carried through a round trip Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`), @@ -69,15 +69,15 @@ func genericFuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { } else { types := []runtime.Object{&metav1.Status{}, &metav1.APIGroup{}} t := types[c.Rand.Intn(len(types))] - c.Fuzz(t) + c.Fill(t) *j = t } }, - func(r *runtime.RawExtension, c fuzz.Continue) { + func(r *runtime.RawExtension, c randfill.Continue) { // Pick an arbitrary type and fuzz it types := []runtime.Object{&metav1.Status{}, &metav1.APIGroup{}} obj := types[c.Rand.Intn(len(types))] - c.Fuzz(obj) + c.Fill(obj) // Find a codec for converting the object to raw bytes. This is necessary for the // api version and kind to be correctly set be serialization. @@ -100,7 +100,7 @@ func genericFuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { } } -// taken from gofuzz internals for RandString +// taken from randfill (nee gofuzz) internals for RandString type charRange struct { first, last rune } @@ -114,7 +114,7 @@ func (c *charRange) choose(r *rand.Rand) rune { // randomLabelPart produces a valid random label value or name-part // of a label key. -func randomLabelPart(c fuzz.Continue, canBeEmpty bool) string { +func randomLabelPart(c randfill.Continue, canBeEmpty bool) string { validStartEnd := []charRange{{'0', '9'}, {'a', 'z'}, {'A', 'Z'}} validMiddle := []charRange{{'0', '9'}, {'a', 'z'}, {'A', 'Z'}, {'.', '.'}, {'-', '-'}, {'_', '_'}} @@ -138,7 +138,7 @@ func randomLabelPart(c fuzz.Continue, canBeEmpty bool) string { return string(runes) } -func randomDNSLabel(c fuzz.Continue) string { +func randomDNSLabel(c randfill.Continue) string { validStartEnd := []charRange{{'0', '9'}, {'a', 'z'}} validMiddle := []charRange{{'0', '9'}, {'a', 'z'}, {'-', '-'}} @@ -154,11 +154,11 @@ func randomDNSLabel(c fuzz.Continue) string { return string(runes) } -func randomLabelKey(c fuzz.Continue) string { +func randomLabelKey(c randfill.Continue) string { namePart := randomLabelPart(c, false) prefixPart := "" - usePrefix := c.RandBool() + usePrefix := c.Bool() if usePrefix { // we can fit, with dots, at most 3 labels in the 253 allotted characters prefixPartsLen := c.Rand.Intn(2) + 1 @@ -175,28 +175,28 @@ func randomLabelKey(c fuzz.Continue) string { func v1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(j *metav1.TypeMeta, c fuzz.Continue) { + func(j *metav1.TypeMeta, c randfill.Continue) { // We have to customize the randomization of TypeMetas because their // APIVersion and Kind must remain blank in memory. j.APIVersion = "" j.Kind = "" }, - func(j *metav1.ObjectMeta, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *metav1.ObjectMeta, c randfill.Continue) { + c.FillNoCustom(j) - j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10) - j.UID = types.UID(c.RandString()) + j.ResourceVersion = strconv.FormatUint(c.Uint64(), 10) + j.UID = types.UID(c.String(0)) // Fuzzing sec and nsec in a smaller range (uint32 instead of int64), // so that the result Unix time is a valid date and can be parsed into RFC3339 format. var sec, nsec uint32 - c.Fuzz(&sec) - c.Fuzz(&nsec) + c.Fill(&sec) + c.Fill(&nsec) j.CreationTimestamp = metav1.Unix(int64(sec), int64(nsec)).Rfc3339Copy() if j.DeletionTimestamp != nil { - c.Fuzz(&sec) - c.Fuzz(&nsec) + c.Fill(&sec) + c.Fill(&nsec) t := metav1.Unix(int64(sec), int64(nsec)).Rfc3339Copy() j.DeletionTimestamp = &t } @@ -218,16 +218,16 @@ func v1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { j.Finalizers = nil } }, - func(j *metav1.ResourceVersionMatch, c fuzz.Continue) { + func(j *metav1.ResourceVersionMatch, c randfill.Continue) { matches := []metav1.ResourceVersionMatch{"", metav1.ResourceVersionMatchExact, metav1.ResourceVersionMatchNotOlderThan} *j = matches[c.Rand.Intn(len(matches))] }, - func(j *metav1.ListMeta, c fuzz.Continue) { - j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10) - j.SelfLink = c.RandString() + func(j *metav1.ListMeta, c randfill.Continue) { + j.ResourceVersion = strconv.FormatUint(c.Uint64(), 10) + j.SelfLink = c.String(0) //nolint:staticcheck // SA1019 backwards compatibility }, - func(j *metav1.LabelSelector, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *metav1.LabelSelector, c randfill.Continue) { + c.FillNoCustom(j) // we can't have an entirely empty selector, so force // use of MatchExpression if necessary if len(j.MatchLabels) == 0 && len(j.MatchExpressions) == 0 { @@ -257,7 +257,7 @@ func v1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { for i := range j.MatchExpressions { req := metav1.LabelSelectorRequirement{} - c.Fuzz(&req) + c.Fill(&req) req.Key = randomLabelKey(c) req.Operator = validOperators[c.Rand.Intn(len(validOperators))] if req.Operator == metav1.LabelSelectorOpIn || req.Operator == metav1.LabelSelectorOpNotIn { @@ -278,8 +278,8 @@ func v1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { sort.Slice(j.MatchExpressions, func(a, b int) bool { return j.MatchExpressions[a].Key < j.MatchExpressions[b].Key }) } }, - func(j *metav1.ManagedFieldsEntry, c fuzz.Continue) { - c.FuzzNoCustom(j) + func(j *metav1.ManagedFieldsEntry, c randfill.Continue) { + c.FillNoCustom(j) j.FieldsV1 = nil }, } @@ -287,15 +287,15 @@ func v1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { func v1beta1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(r *metav1beta1.TableOptions, c fuzz.Continue) { - c.FuzzNoCustom(r) + func(r *metav1beta1.TableOptions, c randfill.Continue) { + c.FillNoCustom(r) // NoHeaders is not serialized to the wire but is allowed within the versioned // type because we don't use meta internal types in the client and API server. r.NoHeaders = false }, - func(r *metav1beta1.TableRow, c fuzz.Continue) { - c.Fuzz(&r.Object) - c.Fuzz(&r.Conditions) + func(r *metav1beta1.TableRow, c randfill.Continue) { + c.Fill(&r.Object) + c.Fill(&r.Conditions) if len(r.Conditions) == 0 { r.Conditions = nil } @@ -307,15 +307,15 @@ func v1beta1FuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{} { t := c.Intn(6) switch t { case 0: - r.Cells[i] = c.RandString() + r.Cells[i] = c.String(0) case 1: r.Cells[i] = c.Int63() case 2: - r.Cells[i] = c.RandBool() + r.Cells[i] = c.Bool() case 3: x := map[string]interface{}{} for j := c.Intn(10) + 1; j >= 0; j-- { - x[c.RandString()] = c.RandString() + x[c.String(0)] = c.String(0) } r.Cells[i] = x case 4: diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go index 66a7a873a9c..39e02cbdc6e 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go @@ -23,9 +23,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/randfill" ) func TestLabelSelectorAsSelector(t *testing.T) { @@ -188,8 +188,8 @@ func TestResetObjectMetaForStatus(t *testing.T) { existingMeta := &ObjectMeta{} // fuzz the existingMeta to set every field, no nils - f := fuzz.New().NilChance(0).NumElements(1, 1).MaxDepth(10) - f.Fuzz(existingMeta) + f := randfill.New().NilChance(0).NumElements(1, 1).MaxDepth(10) + f.Fill(existingMeta) ResetObjectMetaForStatus(meta, existingMeta) // not all fields are stomped during the reset. These fields should not have been set. False diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go index 3cf9d48e961..a5f437b4b38 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go @@ -20,21 +20,22 @@ limitations under the License. package v1 import ( + "math/rand" "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) -// Fuzz satisfies fuzz.Interface. -func (t *MicroTime) Fuzz(c fuzz.Continue) { +// Fuzz satisfies randfill.SimpleSelfFiller. +func (t *MicroTime) RandFill(r *rand.Rand) { if t == nil { return } // Allow for about 1000 years of randomness. Accurate to a tenth of // micro second. Leave off nanoseconds because JSON doesn't // represent them so they can't round-trip properly. - t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 1000*c.Rand.Int63n(1000000)) + t.Time = time.Unix(r.Int63n(1000*365*24*60*60), 1000*r.Int63n(1000000)) } -// ensure MicroTime implements fuzz.Interface -var _ fuzz.Interface = &MicroTime{} +// ensure MicroTime implements randfill.Interface +var _ randfill.SimpleSelfFiller = &MicroTime{} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_test.go index b5e491a6e52..b96baa5b775 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_test.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/yaml" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) type MicroTimeHolder struct { @@ -378,10 +378,10 @@ func TestMicroTimeProtoUnmarshalRaw(t *testing.T) { } func TestMicroTimeRoundtripCBOR(t *testing.T) { - fuzzer := fuzz.New() + fuzzer := randfill.New() for i := 0; i < 500; i++ { var initial, final MicroTime - fuzzer.Fuzz(&initial) + fuzzer.Fill(&initial) b, err := cbor.Marshal(initial) if err != nil { t.Errorf("error encoding %v: %v", initial, err) diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/options_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/options_test.go index 3367a57f07a..5d37987dacc 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/options_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/options_test.go @@ -22,15 +22,15 @@ import ( "reflect" "testing" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func TestPatchOptionsIsSuperSetOfUpdateOptions(t *testing.T) { - f := fuzz.New() + f := randfill.New() for i := 0; i < 1000; i++ { t.Run(fmt.Sprintf("Run %d/1000", i), func(t *testing.T) { update := UpdateOptions{} - f.Fuzz(&update) + f.Fill(&update) b, err := json.Marshal(update) if err != nil { diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go index bf9e21b5bd9..48fb978450e 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go @@ -20,21 +20,22 @@ limitations under the License. package v1 import ( + "math/rand" "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) -// Fuzz satisfies fuzz.Interface. -func (t *Time) Fuzz(c fuzz.Continue) { +// Fuzz satisfies randfill.SimpleSelfFiller. +func (t *Time) RandFill(r *rand.Rand) { if t == nil { return } // Allow for about 1000 years of randomness. Leave off nanoseconds // because JSON doesn't represent them so they can't round-trip // properly. - t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 0) + t.Time = time.Unix(r.Int63n(1000*365*24*60*60), 0) } -// ensure Time implements fuzz.Interface -var _ fuzz.Interface = &Time{} +// ensure Time implements randfill.SimpleSelfFiller +var _ randfill.SimpleSelfFiller = &Time{} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go index 714cb1a76a4..886425f2fb4 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/yaml" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) type TimeHolder struct { @@ -303,10 +303,10 @@ func TestTimeIsZero(t *testing.T) { } func TestTimeRoundtripCBOR(t *testing.T) { - fuzzer := fuzz.New() + fuzzer := randfill.New() for i := 0; i < 500; i++ { var initial, final Time - fuzzer.Fuzz(&initial) + fuzzer.Fill(&initial) b, err := cbor.Marshal(initial) if err != nil { t.Errorf("error encoding %v: %v", initial, err) diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go index 3eda144f8d1..889083eccb1 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go @@ -28,8 +28,8 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/api/equality" @@ -67,7 +67,7 @@ func TestUnstructuredMetadataRoundTrip(t *testing.T) { u := &unstructured.Unstructured{Object: map[string]interface{}{}} uCopy := u.DeepCopy() metadata := &metav1.ObjectMeta{} - fuzzer.Fuzz(metadata) + fuzzer.Fill(metadata) if err := setObjectMeta(u, metadata); err != nil { t.Fatalf("unexpected error setting fuzzed ObjectMeta: %v", err) @@ -94,7 +94,7 @@ func TestUnstructuredMetadataOmitempty(t *testing.T) { // fuzz to make sure we don't miss any function calls below u := &unstructured.Unstructured{Object: map[string]interface{}{}} metadata := &metav1.ObjectMeta{} - fuzzer.Fuzz(metadata) + fuzzer.Fill(metadata) if err := setObjectMeta(u, metadata); err != nil { t.Fatalf("unexpected error setting fuzzed ObjectMeta: %v", err) } @@ -184,7 +184,7 @@ func roundtripType[U runtime.Unstructured](t *testing.T) { for i := 0; i < 50; i++ { original := reflect.New(reflect.TypeFor[U]().Elem()).Interface().(runtime.Unstructured) - fuzzer.Fuzz(original) + fuzzer.Fill(original) // unstructured -> JSON > unstructured > CBOR -> unstructured -> JSON -> unstructured roundtrip(t, original, jS, cS) // unstructured -> CBOR > unstructured > JSON -> unstructured -> CBOR -> unstructured @@ -285,25 +285,25 @@ const ( func unstructuredFuzzerFuncs(codecs serializer.CodecFactory) []interface{} { return []interface{}{ - func(u *unstructured.Unstructured, c fuzz.Continue) { + func(u *unstructured.Unstructured, c randfill.Continue) { obj := make(map[string]interface{}) obj["apiVersion"] = generateValidAPIVersionString(c) obj["kind"] = generateNonEmptyString(c) for j := c.Intn(maxUnstructuredFanOut); j >= 0; j-- { - obj[c.RandString()] = generateRandomTypeValue(maxUnstructuredDepth, c) + obj[c.String(0)] = generateRandomTypeValue(maxUnstructuredDepth, c) } u.Object = obj }, - func(ul *unstructured.UnstructuredList, c fuzz.Continue) { + func(ul *unstructured.UnstructuredList, c randfill.Continue) { obj := make(map[string]interface{}) obj["apiVersion"] = generateValidAPIVersionString(c) obj["kind"] = generateNonEmptyString(c) for j := c.Intn(maxUnstructuredFanOut); j >= 0; j-- { - obj[c.RandString()] = generateRandomTypeValue(maxUnstructuredDepth, c) + obj[c.String(0)] = generateRandomTypeValue(maxUnstructuredDepth, c) } for j := c.Intn(maxUnstructuredFanOut); j >= 0; j-- { var item = unstructured.Unstructured{} - c.Fuzz(&item) + c.Fill(&item) ul.Items = append(ul.Items, item) } ul.Object = obj @@ -311,16 +311,16 @@ func unstructuredFuzzerFuncs(codecs serializer.CodecFactory) []interface{} { } } -func generateNonEmptyString(c fuzz.Continue) string { - temp := c.RandString() +func generateNonEmptyString(c randfill.Continue) string { + temp := c.String(0) for len(temp) == 0 { - temp = c.RandString() + temp = c.String(0) } return temp } // generateNonEmptyNoSlashString generates a non-empty string without any slashes -func generateNonEmptyNoSlashString(c fuzz.Continue) string { +func generateNonEmptyNoSlashString(c randfill.Continue) string { temp := strings.ReplaceAll(generateNonEmptyString(c), "/", "") for len(temp) == 0 { temp = strings.ReplaceAll(generateNonEmptyString(c), "/", "") @@ -330,8 +330,8 @@ func generateNonEmptyNoSlashString(c fuzz.Continue) string { // generateValidAPIVersionString generates valid apiVersion string with formats: // / or -func generateValidAPIVersionString(c fuzz.Continue) string { - if c.RandBool() { +func generateValidAPIVersionString(c randfill.Continue) string { + if c.Bool() { return generateNonEmptyNoSlashString(c) + "/" + generateNonEmptyNoSlashString(c) } else { return generateNonEmptyNoSlashString(c) @@ -355,7 +355,7 @@ func generateValidAPIVersionString(c fuzz.Continue) string { // All external-versioned builtin types are exercised through RoundtripToUnstructured // in apitesting package. Types like metav1.Time are implicitly being exercised // because they appear as fields in those types. -func generateRandomTypeValue(depth int, c fuzz.Continue) interface{} { +func generateRandomTypeValue(depth int, c randfill.Continue) interface{} { t := c.Rand.Intn(120) // If the max depth for unstructured is reached, only add non-recursive types // which is 20+ in range @@ -373,21 +373,21 @@ func generateRandomTypeValue(depth int, c fuzz.Continue) interface{} { case t < 20: item := map[string]interface{}{} for j := c.Intn(maxUnstructuredFanOut); j >= 0; j-- { - item[c.RandString()] = generateRandomTypeValue(depth-1, c) + item[c.String(0)] = generateRandomTypeValue(depth-1, c) } return item case t < 40: // Only valid UTF-8 encodings var item string - c.Fuzz(&item) + c.Fill(&item) return item case t < 60: var item int64 - c.Fuzz(&item) + c.Fill(&item) return item case t < 80: var item bool - c.Fuzz(&item) + c.Fill(&item) return item case t < 100: return c.Rand.NormFloat64() diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/fuzzer.go b/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/fuzzer.go index 26d7ddd889b..ff982397139 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/fuzzer/fuzzer.go @@ -19,12 +19,12 @@ package fuzzer import ( "fmt" - "github.com/google/gofuzz" + "sigs.k8s.io/randfill" apitesting "k8s.io/apimachinery/pkg/api/apitesting" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/apis/testapigroup" - "k8s.io/apimachinery/pkg/apis/testapigroup/v1" + v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1" "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" ) @@ -33,9 +33,9 @@ import ( // values in a Kubernetes context. func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(j *runtime.Object, c fuzz.Continue) { + func(j *runtime.Object, c randfill.Continue) { // TODO: uncomment when round trip starts from a versioned object - if true { //c.RandBool() { + if true { // c.Bool() { *j = &runtime.Unknown{ // We do not set TypeMeta here because it is not carried through a round trip Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`), @@ -44,15 +44,15 @@ func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} { } else { types := []runtime.Object{&testapigroup.Carp{}} t := types[c.Rand.Intn(len(types))] - c.Fuzz(t) + c.Fill(t) *j = t } }, - func(r *runtime.RawExtension, c fuzz.Continue) { + func(r *runtime.RawExtension, c randfill.Continue) { // Pick an arbitrary type and fuzz it types := []runtime.Object{&testapigroup.Carp{}} obj := types[c.Rand.Intn(len(types))] - c.Fuzz(obj) + c.Fill(obj) // Convert the object to raw bytes bytes, err := runtime.Encode(apitesting.TestCodec(codecs, v1.SchemeGroupVersion), obj) @@ -68,11 +68,11 @@ func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} { func testapigroupFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *testapigroup.CarpSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *testapigroup.CarpSpec, c randfill.Continue) { + c.FillNoCustom(s) // has a default value ttl := int64(30) - if c.RandBool() { + if c.Bool() { ttl = int64(c.Uint32()) } s.TerminationGracePeriodSeconds = &ttl @@ -81,11 +81,11 @@ func testapigroupFuncs(codecs runtimeserializer.CodecFactory) []interface{} { s.SchedulerName = "default-scheduler" } }, - func(j *testapigroup.CarpPhase, c fuzz.Continue) { + func(j *testapigroup.CarpPhase, c randfill.Continue) { statuses := []testapigroup.CarpPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"} *j = statuses[c.Rand.Intn(len(statuses))] }, - func(rp *testapigroup.RestartPolicy, c fuzz.Continue) { + func(rp *testapigroup.RestartPolicy, c randfill.Continue) { policies := []testapigroup.RestartPolicy{"Always", "Never", "OnFailure"} *rp = policies[c.Rand.Intn(len(policies))] }, diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/converter_test.go b/staging/src/k8s.io/apimachinery/pkg/runtime/converter_test.go index eebbf03880e..14c1ff547b3 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/converter_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/converter_test.go @@ -36,9 +36,9 @@ import ( "k8s.io/apimachinery/pkg/util/json" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" ) var simpleEquality = conversion.EqualitiesOrDie( @@ -640,9 +640,9 @@ func TestUnknownFields(t *testing.T) { // with the various validation directives (Ignore, Warn, Strict) func BenchmarkFromUnstructuredWithValidation(b *testing.B) { re := regexp.MustCompile("^I$") - f := fuzz.NewWithSeed(1).NilChance(0.1).SkipFieldsWithPattern(re) + f := randfill.NewWithSeed(1).NilChance(0.1).SkipFieldsWithPattern(re) iObj := &I{} - f.Fuzz(&iObj) + f.Fill(&iObj) unstr, err := runtime.DefaultUnstructuredConverter.ToUnstructured(iObj) if err != nil { diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go index d4bfb69b3c7..ceb6f93da8f 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go @@ -34,8 +34,8 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" flag "github.com/spf13/pflag" + "sigs.k8s.io/randfill" "sigs.k8s.io/yaml" ) @@ -61,9 +61,9 @@ func (testMetaFactory) Interpret(data []byte) (*schema.GroupVersionKind, error) } // TestObjectFuzzer can randomly populate all the above objects. -var TestObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 100).Funcs( - func(j *runtimetesting.MyWeirdCustomEmbeddedVersionKindField, c fuzz.Continue) { - c.FuzzNoCustom(j) +var TestObjectFuzzer = randfill.New().NilChance(.5).NumElements(1, 100).Funcs( + func(j *runtimetesting.MyWeirdCustomEmbeddedVersionKindField, c randfill.Continue) { + c.FillNoCustom(j) j.APIVersion = "" j.ObjectKind = "" }, @@ -106,7 +106,7 @@ var semantic = conversion.EqualitiesOrDie( func runTest(t *testing.T, source interface{}) { name := reflect.TypeOf(source).Elem().Name() - TestObjectFuzzer.Fuzz(source) + TestObjectFuzzer.Fill(source) _, codec := GetTestScheme() data, err := runtime.Encode(codec, source.(runtime.Object)) diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/collections_test.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/collections_test.go index 03ec4d88f22..57859e46dd6 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/collections_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/collections_test.go @@ -22,12 +22,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" testapigroupv1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1" "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/randfill" ) func TestCollectionsEncoding(t *testing.T) { @@ -720,35 +720,35 @@ func (b *writeCountingBuffer) Reset() { } func TestFuzzCollectionsEncoding(t *testing.T) { - disableFuzzFieldsV1 := func(field *metav1.FieldsV1, c fuzz.Continue) {} - fuzzUnstructuredList := func(list *unstructured.UnstructuredList, c fuzz.Continue) { + disableFuzzFieldsV1 := func(field *metav1.FieldsV1, c randfill.Continue) {} + fuzzUnstructuredList := func(list *unstructured.UnstructuredList, c randfill.Continue) { list.Object = map[string]interface{}{ - "kind": "List", - "apiVersion": "v1", - c.RandString(): c.RandString(), - c.RandString(): c.RandUint64(), - c.RandString(): c.RandBool(), + "kind": "List", + "apiVersion": "v1", + c.String(0): c.String(0), + c.String(0): c.Uint64(), + c.String(0): c.Bool(), "metadata": map[string]interface{}{ - "resourceVersion": fmt.Sprintf("%d", c.RandUint64()), - "continue": c.RandString(), - "remainingItemCount": fmt.Sprintf("%d", c.RandUint64()), - c.RandString(): c.RandString(), + "resourceVersion": fmt.Sprintf("%d", c.Uint64()), + "continue": c.String(0), + "remainingItemCount": fmt.Sprintf("%d", c.Uint64()), + c.String(0): c.String(0), }} - c.Fuzz(&list.Items) + c.Fill(&list.Items) } - fuzzMap := func(kvs map[string]interface{}, c fuzz.Continue) { - kvs[c.RandString()] = c.RandBool() - kvs[c.RandString()] = c.RandUint64() - kvs[c.RandString()] = c.RandString() + fuzzMap := func(kvs map[string]interface{}, c randfill.Continue) { + kvs[c.String(0)] = c.Bool() + kvs[c.String(0)] = c.Uint64() + kvs[c.String(0)] = c.String(0) } - f := fuzz.New().Funcs(disableFuzzFieldsV1, fuzzUnstructuredList, fuzzMap) + f := randfill.New().Funcs(disableFuzzFieldsV1, fuzzUnstructuredList, fuzzMap) streamingBuffer := &bytes.Buffer{} normalSerializer := NewSerializerWithOptions(DefaultMetaFactory, nil, nil, SerializerOptions{StreamingCollectionsEncoding: false}) normalBuffer := &bytes.Buffer{} t.Run("CarpList", func(t *testing.T) { for i := 0; i < 1000; i++ { list := &testapigroupv1.CarpList{} - f.Fuzz(list) + f.Fill(list) streamingBuffer.Reset() normalBuffer.Reset() ok, err := streamEncodeCollections(list, streamingBuffer) @@ -771,7 +771,7 @@ func TestFuzzCollectionsEncoding(t *testing.T) { t.Run("UnstructuredList", func(t *testing.T) { for i := 0; i < 1000; i++ { list := &unstructured.UnstructuredList{} - f.Fuzz(list) + f.Fill(list) streamingBuffer.Reset() normalBuffer.Reset() ok, err := streamEncodeCollections(list, streamingBuffer) diff --git a/staging/src/k8s.io/apimachinery/pkg/test/api_meta_help_test.go b/staging/src/k8s.io/apimachinery/pkg/test/api_meta_help_test.go index 4214c1b3ee6..e6be1331119 100644 --- a/staging/src/k8s.io/apimachinery/pkg/test/api_meta_help_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/test/api_meta_help_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/api/meta" metafuzzer "k8s.io/apimachinery/pkg/apis/meta/fuzzer" @@ -312,10 +312,10 @@ func TestSetListToMatchingType(t *testing.T) { func TestSetExtractListRoundTrip(t *testing.T) { scheme := runtime.NewScheme() codecs := serializer.NewCodecFactory(scheme) - fuzzer := fuzz.New().NilChance(0).NumElements(1, 5).Funcs(metafuzzer.Funcs(codecs)...).MaxDepth(10) + fuzzer := randfill.New().NilChance(0).NumElements(1, 5).Funcs(metafuzzer.Funcs(codecs)...).MaxDepth(10) for i := 0; i < 5; i++ { start := &testapigroup.CarpList{} - fuzzer.Fuzz(&start.Items) + fuzzer.Fill(&start.Items) list, err := meta.ExtractList(start) if err != nil { diff --git a/staging/src/k8s.io/apimachinery/pkg/test/api_meta_meta_test.go b/staging/src/k8s.io/apimachinery/pkg/test/api_meta_meta_test.go index ccd80544581..02c63f2041b 100644 --- a/staging/src/k8s.io/apimachinery/pkg/test/api_meta_meta_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/test/api_meta_meta_test.go @@ -20,7 +20,6 @@ import ( "reflect" "testing" - fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/meta" metafuzzer "k8s.io/apimachinery/pkg/apis/meta/fuzzer" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -29,6 +28,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/randfill" ) func TestAPIObjectMeta(t *testing.T) { @@ -306,7 +306,7 @@ type MyAPIObject2 struct { func getObjectMetaAndOwnerReferences() (myAPIObject2 MyAPIObject2, metaOwnerReferences []metav1.OwnerReference) { scheme := runtime.NewScheme() codecs := serializer.NewCodecFactory(scheme) - fuzz.New().NilChance(.5).NumElements(1, 5).Funcs(metafuzzer.Funcs(codecs)...).MaxDepth(10).Fuzz(&myAPIObject2) + randfill.New().NilChance(.5).NumElements(1, 5).Funcs(metafuzzer.Funcs(codecs)...).MaxDepth(10).Fill(&myAPIObject2) references := myAPIObject2.ObjectMeta.OwnerReferences // This is necessary for the test to pass because the getter will return a // non-nil slice. diff --git a/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go b/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go index a502b5adb69..2d6f6a0ccca 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go @@ -20,24 +20,24 @@ limitations under the License. package intstr import ( - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) -// Fuzz satisfies fuzz.Interface -func (intstr *IntOrString) Fuzz(c fuzz.Continue) { +// RandFill satisfies randfill.NativeSelfFiller +func (intstr *IntOrString) RandFill(c randfill.Continue) { if intstr == nil { return } - if c.RandBool() { + if c.Bool() { intstr.Type = Int - c.Fuzz(&intstr.IntVal) + c.Fill(&intstr.IntVal) intstr.StrVal = "" } else { intstr.Type = String intstr.IntVal = 0 - c.Fuzz(&intstr.StrVal) + c.Fill(&intstr.StrVal) } } // ensure IntOrString implements fuzz.Interface -var _ fuzz.Interface = &IntOrString{} +var _ randfill.NativeSelfFiller = &IntOrString{} diff --git a/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr_test.go b/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr_test.go index ecf47ce0da8..eb63854bbc9 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr_test.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/yaml" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func TestFromInt(t *testing.T) { @@ -544,10 +544,10 @@ func TestUnmarshalCBOR(t *testing.T) { } func TestIntOrStringRoundtripCBOR(t *testing.T) { - fuzzer := fuzz.New() + fuzzer := randfill.New() for i := 0; i < 500; i++ { var initial, final IntOrString - fuzzer.Fuzz(&initial) + fuzzer.Fill(&initial) b, err := cbor.Marshal(initial) if err != nil { t.Errorf("error encoding %v: %v", initial, err) diff --git a/staging/src/k8s.io/apiserver/go.mod b/staging/src/k8s.io/apiserver/go.mod index f9807a026a4..20a777bd962 100644 --- a/staging/src/k8s.io/apiserver/go.mod +++ b/staging/src/k8s.io/apiserver/go.mod @@ -18,7 +18,6 @@ require ( github.com/google/cel-go v0.23.2 github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 @@ -55,11 +54,12 @@ require ( k8s.io/component-base v0.0.0 k8s.io/klog/v2 v2.130.1 k8s.io/kms v0.0.0 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 sigs.k8s.io/yaml v1.4.0 ) diff --git a/staging/src/k8s.io/apiserver/go.sum b/staging/src/k8s.io/apiserver/go.sum index 9d8454f401a..66ad7dff5aa 100644 --- a/staging/src/k8s.io/apiserver/go.sum +++ b/staging/src/k8s.io/apiserver/go.sum @@ -220,8 +220,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -512,15 +510,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors_test.go b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors_test.go index 7469d4eb678..a4100c25516 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors_test.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors_test.go @@ -22,16 +22,16 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" v1 "k8s.io/api/admissionregistration/v1" + "sigs.k8s.io/randfill" ) func TestMutatingWebhookAccessor(t *testing.T) { - f := fuzz.New() + f := randfill.New() for i := 0; i < 100; i++ { t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) { orig := &v1.MutatingWebhook{} - f.Fuzz(orig) + f.Fill(orig) // zero out any accessor type specific fields not included in the accessor orig.ReinvocationPolicy = nil @@ -72,11 +72,11 @@ func TestMutatingWebhookAccessor(t *testing.T) { } func TestValidatingWebhookAccessor(t *testing.T) { - f := fuzz.New() + f := randfill.New() for i := 0; i < 100; i++ { t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) { orig := &v1.ValidatingWebhook{} - f.Fuzz(orig) + f.Fill(orig) uid := fmt.Sprintf("test.configuration.admission/%s/0", orig.Name) accessor := NewValidatingWebhookAccessor(uid, "test.configuration.admission", orig) if uid != accessor.GetUID() { diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apidiscovery/v2/fuzzer_test.go b/staging/src/k8s.io/apiserver/pkg/apis/apidiscovery/v2/fuzzer_test.go index 44bc038d92f..420ad0867c4 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/apidiscovery/v2/fuzzer_test.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/apidiscovery/v2/fuzzer_test.go @@ -29,8 +29,8 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" ) func TestConversionRoundTrip(t *testing.T) { @@ -42,12 +42,12 @@ func TestConversionRoundTrip(t *testing.T) { err = v2scheme.RegisterConversions(scheme) require.NoError(t, err) - fuzzer := fuzz.NewWithSeed(2374375) + fuzzer := randfill.NewWithSeed(2374375) // v2 -> v2beta1 -> v2 for i := 0; i < 100; i++ { expected := &v2.APIGroupDiscoveryList{} - fuzzer.Fuzz(expected) + fuzzer.Fill(expected) expected.TypeMeta = metav1.TypeMeta{ Kind: "APIGroupDiscoveryList", APIVersion: "apidiscovery.k8s.io/v2", @@ -68,7 +68,7 @@ func TestConversionRoundTrip(t *testing.T) { // v2beta1 -> v2 -> v2beta1 for i := 0; i < 100; i++ { expected := &v2beta1.APIGroupDiscoveryList{} - fuzzer.Fuzz(expected) + fuzzer.Fill(expected) expected.TypeMeta = metav1.TypeMeta{ Kind: "APIGroupDiscoveryList", APIVersion: "apidiscovery.k8s.io/v2beta1", diff --git a/staging/src/k8s.io/apiserver/pkg/apis/audit/fuzzer/fuzzer.go b/staging/src/k8s.io/apiserver/pkg/apis/audit/fuzzer/fuzzer.go index 5b0b0046ff8..8f3da59d8fc 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/audit/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/audit/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "strings" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" @@ -29,9 +29,9 @@ import ( // Funcs returns the fuzzer functions for the audit api group. func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(e *audit.Event, c fuzz.Continue) { - c.FuzzNoCustom(e) - switch c.RandBool() { + func(e *audit.Event, c randfill.Continue) { + c.FillNoCustom(e) + switch c.Bool() { case true: e.RequestObject = nil case false: @@ -41,7 +41,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { ContentType: runtime.ContentTypeJSON, } } - switch c.RandBool() { + switch c.Bool() { case true: e.ResponseObject = nil case false: @@ -52,8 +52,8 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { } } }, - func(o *audit.ObjectReference, c fuzz.Continue) { - c.FuzzNoCustom(o) + func(o *audit.ObjectReference, c randfill.Continue) { + c.FillNoCustom(o) switch c.Intn(3) { case 0: // core api group diff --git a/staging/src/k8s.io/apiserver/pkg/apis/example/fuzzer/fuzzer.go b/staging/src/k8s.io/apiserver/pkg/apis/example/fuzzer/fuzzer.go index 58c08540694..d8c8ed14d4a 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/example/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/example/fuzzer/fuzzer.go @@ -19,7 +19,7 @@ package fuzzer import ( "fmt" - "github.com/google/gofuzz" + "sigs.k8s.io/randfill" apitesting "k8s.io/apimachinery/pkg/api/apitesting" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" @@ -33,9 +33,9 @@ import ( // values in a Kubernetes context. func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(j *runtime.Object, c fuzz.Continue) { + func(j *runtime.Object, c randfill.Continue) { // TODO: uncomment when round trip starts from a versioned object - if true { //c.RandBool() { + if true { // c.Bool() { *j = &runtime.Unknown{ // We do not set TypeMeta here because it is not carried through a round trip Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`), @@ -44,15 +44,15 @@ func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} { } else { types := []runtime.Object{&example.Pod{}} t := types[c.Rand.Intn(len(types))] - c.Fuzz(t) + c.Fill(t) *j = t } }, - func(r *runtime.RawExtension, c fuzz.Continue) { + func(r *runtime.RawExtension, c randfill.Continue) { // Pick an arbitrary type and fuzz it types := []runtime.Object{&example.Pod{}} obj := types[c.Rand.Intn(len(types))] - c.Fuzz(obj) + c.Fill(obj) // Convert the object to raw bytes bytes, err := runtime.Encode(apitesting.TestCodec(codecs, examplev1.SchemeGroupVersion), obj) @@ -68,11 +68,11 @@ func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} { func exampleFuncs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *example.PodSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) + func(s *example.PodSpec, c randfill.Continue) { + c.FillNoCustom(s) // has a default value ttl := int64(30) - if c.RandBool() { + if c.Bool() { ttl = int64(c.Uint32()) } s.TerminationGracePeriodSeconds = &ttl @@ -81,11 +81,11 @@ func exampleFuncs(codecs runtimeserializer.CodecFactory) []interface{} { s.SchedulerName = "default-scheduler" } }, - func(j *example.PodPhase, c fuzz.Continue) { + func(j *example.PodPhase, c randfill.Continue) { statuses := []example.PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"} *j = statuses[c.Rand.Intn(len(statuses))] }, - func(rp *example.RestartPolicy, c fuzz.Continue) { + func(rp *example.RestartPolicy, c randfill.Continue) { policies := []example.RestartPolicy{"Always", "Never", "OnFailure"} *rp = policies[c.Rand.Intn(len(policies))] }, diff --git a/staging/src/k8s.io/apiserver/pkg/cel/escaping_test.go b/staging/src/k8s.io/apiserver/pkg/cel/escaping_test.go index 72b669c6916..3d6fec64c76 100644 --- a/staging/src/k8s.io/apiserver/pkg/cel/escaping_test.go +++ b/staging/src/k8s.io/apiserver/pkg/cel/escaping_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) // TestEscaping tests that property names are escaped as expected. @@ -143,10 +143,10 @@ func TestUnescapeMalformed(t *testing.T) { } func TestEscapingFuzz(t *testing.T) { - fuzzer := fuzz.New() + fuzzer := randfill.New() for i := 0; i < 1000; i++ { var unescaped string - fuzzer.Fuzz(&unescaped) + fuzzer.Fill(&unescaped) t.Run(fmt.Sprintf("%d - '%s'", i, unescaped), func(t *testing.T) { if len(unescaped) == 0 { return diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go index a7a3d367c62..93cb60859c2 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go @@ -4463,7 +4463,7 @@ func benchmarkItems(b *testing.B) []example.Pod { clientapiObjectFuzzer := fuzzer.FuzzerFor(examplefuzzer.Funcs, rand.NewSource(benchmarkSeed), codecs) items := make([]example.Pod, 3) for i := range items { - clientapiObjectFuzzer.Fuzz(&items[i]) + clientapiObjectFuzzer.Fill(&items[i]) } return items } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/aggregated/handler_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/aggregated/handler_test.go index 4b4fa0b58f5..34b0cd37ae7 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/aggregated/handler_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/discovery/aggregated/handler_test.go @@ -29,9 +29,9 @@ import ( "sync" "testing" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" apidiscoveryv2 "k8s.io/api/apidiscovery/v2" apidiscoveryv2beta1 "k8s.io/api/apidiscovery/v2beta1" @@ -59,16 +59,16 @@ func init() { } func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv2.APIGroupDiscoveryList { - fuzzer := fuzz.NewWithSeed(seed) + fuzzer := randfill.NewWithSeed(seed) fuzzer.NumElements(atLeastNumGroups, maxNumGroups) fuzzer.NilChance(0) - fuzzer.Funcs(func(o *apidiscoveryv2.APIGroupDiscovery, c fuzz.Continue) { - c.FuzzNoCustom(o) + fuzzer.Funcs(func(o *apidiscoveryv2.APIGroupDiscovery, c randfill.Continue) { + c.FillNoCustom(o) // The ResourceManager will just not serve the group if its versions // list is empty atLeastOne := apidiscoveryv2.APIVersionDiscovery{} - c.Fuzz(&atLeastOne) + c.Fill(&atLeastOne) o.Versions = append(o.Versions, atLeastOne) sort.Slice(o.Versions[:], func(i, j int) bool { return version.CompareKubeAwareVersionStrings(o.Versions[i].Version, o.Versions[j].Version) > 0 @@ -76,14 +76,14 @@ func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv o.TypeMeta = metav1.TypeMeta{} var name string - c.Fuzz(&name) + c.Fill(&name) o.ObjectMeta = metav1.ObjectMeta{ Name: name, } }) var apis []apidiscoveryv2.APIGroupDiscovery - fuzzer.Fuzz(&apis) + fuzzer.Fill(&apis) sort.Slice(apis[:], func(i, j int) bool { return apis[i].Name < apis[j].Name }) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go index 995063e5cd9..2f9412073c2 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go @@ -28,7 +28,6 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" jsonpatch "gopkg.in/evanphx/json-patch.v4" apiequality "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -53,6 +52,7 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/component-base/metrics/legacyregistry" "k8s.io/component-base/metrics/testutil" + "sigs.k8s.io/randfill" ) var ( @@ -991,11 +991,11 @@ func (alwaysErrorTyper) Recognizes(gvk schema.GroupVersionKind) bool { } func TestUpdateToCreateOptions(t *testing.T) { - f := fuzz.New() + f := randfill.New() for i := 0; i < 100; i++ { t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) { update := &metav1.UpdateOptions{} - f.Fuzz(update) + f.Fill(update) create := updateToCreateOptions(update) b, err := json.Marshal(create) @@ -1038,13 +1038,13 @@ func TestPatchToUpdateOptions(t *testing.T) { }, } - f := fuzz.New() + f := randfill.New() for _, test := range tests { t.Run(test.name, func(t *testing.T) { for i := 0; i < 100; i++ { t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) { patch := &metav1.PatchOptions{} - f.Fuzz(patch) + f.Fill(patch) converted := test.converterFn(patch) b, err := json.Marshal(converted) diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go index 3cfb4f3427d..75796170160 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go @@ -29,7 +29,7 @@ import ( "testing" "time" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/api/apitesting" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -480,13 +480,13 @@ func TestStoreCreateWithRetryNameGenerateFeatureDisabled(t *testing.T) { } func TestNewCreateOptionsFromUpdateOptions(t *testing.T) { - f := fuzz.New().NilChance(0.0).NumElements(1, 1) + f := randfill.New().NilChance(0.0).NumElements(1, 1) // The goal here is to trigger when any changes are made to either // CreateOptions or UpdateOptions types, so we can update the converter. for i := 0; i < 20; i++ { in := &metav1.UpdateOptions{} - f.Fuzz(in) + f.Fill(in) in.TypeMeta.SetGroupVersionKind(metav1.SchemeGroupVersion.WithKind("CreateOptions")) out := newCreateOptionsFromUpdateOptions(in) @@ -532,13 +532,13 @@ func TestNewCreateOptionsFromUpdateOptions(t *testing.T) { } func TestNewDeleteOptionsFromUpdateOptions(t *testing.T) { - f := fuzz.New().NilChance(0.0).NumElements(1, 1) + f := randfill.New().NilChance(0.0).NumElements(1, 1) // The goal here is to trigger when any changes are made to either // DeleteOptions or UpdateOptions types, so we can update the converter. for i := 0; i < 20; i++ { in := &metav1.UpdateOptions{} - f.Fuzz(in) + f.Fill(in) in.TypeMeta.SetGroupVersionKind(metav1.SchemeGroupVersion.WithKind("DeleteOptions")) out := newDeleteOptionsFromUpdateOptions(in) diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/round_trip_test.go b/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/round_trip_test.go index 75c9dbf9282..615ba21aab6 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/round_trip_test.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/round_trip_test.go @@ -24,22 +24,22 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" authenticationv1 "k8s.io/api/authentication/v1" authenticationv1beta1 "k8s.io/api/authentication/v1beta1" ) func TestRoundTrip(t *testing.T) { - f := fuzz.New() + f := randfill.New() seed := time.Now().UnixNano() t.Logf("seed = %v", seed) f.RandSource(rand.New(rand.NewSource(seed))) for i := 0; i < 1000; i++ { original := &authenticationv1.TokenReview{} - f.Fuzz(&original.Spec) - f.Fuzz(&original.Status) + f.Fill(&original.Spec) + f.Fill(&original.Status) converted := &authenticationv1beta1.TokenReview{ Spec: v1SpecToV1beta1Spec(&original.Spec), Status: v1StatusToV1beta1Status(original.Status), diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/round_trip_test.go b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/round_trip_test.go index 73f6adf006c..56011638de7 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/round_trip_test.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/round_trip_test.go @@ -24,22 +24,22 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" authorizationv1 "k8s.io/api/authorization/v1" authorizationv1beta1 "k8s.io/api/authorization/v1beta1" ) func TestRoundTrip(t *testing.T) { - f := fuzz.New() + f := randfill.New() seed := time.Now().UnixNano() t.Logf("seed = %v", seed) f.RandSource(rand.New(rand.NewSource(seed))) for i := 0; i < 1000; i++ { original := &authorizationv1.SubjectAccessReview{} - f.Fuzz(&original.Spec) - f.Fuzz(&original.Status) + f.Fill(&original.Spec) + f.Fill(&original.Status) converted := &authorizationv1beta1.SubjectAccessReview{ Spec: v1SpecToV1beta1Spec(&original.Spec), Status: v1StatusToV1beta1Status(original.Status), diff --git a/staging/src/k8s.io/cli-runtime/go.mod b/staging/src/k8s.io/cli-runtime/go.mod index 339bb4f417f..248d23f3e8a 100644 --- a/staging/src/k8s.io/cli-runtime/go.mod +++ b/staging/src/k8s.io/cli-runtime/go.mod @@ -22,7 +22,7 @@ require ( k8s.io/apimachinery v0.0.0 k8s.io/client-go v0.0.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/kustomize/api v0.19.0 sigs.k8s.io/kustomize/kyaml v0.19.0 @@ -42,7 +42,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/btree v1.1.3 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -67,7 +66,8 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect ) replace ( diff --git a/staging/src/k8s.io/cli-runtime/go.sum b/staging/src/k8s.io/cli-runtime/go.sum index 81aed753ae6..8c76cae4044 100644 --- a/staging/src/k8s.io/cli-runtime/go.sum +++ b/staging/src/k8s.io/cli-runtime/go.sum @@ -41,8 +41,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -182,8 +180,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= @@ -192,7 +190,10 @@ sigs.k8s.io/kustomize/api v0.19.0 h1:F+2HB2mU1MSiR9Hp1NEgoU2q9ItNOaBJl0I4Dlus5SQ sigs.k8s.io/kustomize/api v0.19.0/go.mod h1:/BbwnivGVcBh1r+8m3tH1VNxJmHSk1PzP5fkP6lbL1o= sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA= sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/client-go/go.mod b/staging/src/k8s.io/client-go/go.mod index a29e5b0e9c2..3da3b0d404a 100644 --- a/staging/src/k8s.io/client-go/go.mod +++ b/staging/src/k8s.io/client-go/go.mod @@ -11,7 +11,6 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 @@ -29,10 +28,11 @@ require ( k8s.io/api v0.0.0 k8s.io/apimachinery v0.0.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 sigs.k8s.io/yaml v1.4.0 ) diff --git a/staging/src/k8s.io/client-go/go.sum b/staging/src/k8s.io/client-go/go.sum index a33bec7c309..4d0c31da3b4 100644 --- a/staging/src/k8s.io/client-go/go.sum +++ b/staging/src/k8s.io/client-go/go.sum @@ -34,8 +34,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -161,13 +159,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/client-go/rest/config_test.go b/staging/src/k8s.io/client-go/rest/config_test.go index 6475813fc3f..9323d4cce73 100644 --- a/staging/src/k8s.io/client-go/rest/config_test.go +++ b/staging/src/k8s.io/client-go/rest/config_test.go @@ -39,9 +39,9 @@ import ( "k8s.io/client-go/util/flowcontrol" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" ) func TestIsConfigTransportTLS(t *testing.T) { @@ -313,60 +313,60 @@ func (fakeAuthProviderConfigPersister) Persist(map[string]string) error { var fakeAuthProviderConfigPersisterError = errors.New("fakeAuthProviderConfigPersisterError") func TestAnonymousAuthConfig(t *testing.T) { - f := fuzz.New().NilChance(0.0).NumElements(1, 1) + f := randfill.New().NilChance(0.0).NumElements(1, 1) f.Funcs( - func(r *runtime.Codec, f fuzz.Continue) { + func(r *runtime.Codec, f randfill.Continue) { codec := &fakeCodec{} - f.Fuzz(codec) + f.Fill(codec) *r = codec }, - func(r *http.RoundTripper, f fuzz.Continue) { + func(r *http.RoundTripper, f randfill.Continue) { roundTripper := &fakeRoundTripper{} - f.Fuzz(roundTripper) + f.Fill(roundTripper) *r = roundTripper }, - func(fn *func(http.RoundTripper) http.RoundTripper, f fuzz.Continue) { + func(fn *func(http.RoundTripper) http.RoundTripper, f randfill.Continue) { *fn = fakeWrapperFunc }, - func(fn *transport.WrapperFunc, f fuzz.Continue) { + func(fn *transport.WrapperFunc, f randfill.Continue) { *fn = fakeWrapperFunc }, - func(r *runtime.NegotiatedSerializer, f fuzz.Continue) { + func(r *runtime.NegotiatedSerializer, f randfill.Continue) { serializer := &fakeNegotiatedSerializer{} - f.Fuzz(serializer) + f.Fill(serializer) *r = serializer }, - func(r *flowcontrol.RateLimiter, f fuzz.Continue) { + func(r *flowcontrol.RateLimiter, f randfill.Continue) { limiter := &fakeLimiter{} - f.Fuzz(limiter) + f.Fill(limiter) *r = limiter }, - func(h *WarningHandler, f fuzz.Continue) { + func(h *WarningHandler, f randfill.Continue) { *h = &fakeWarningHandler{} }, - func(h *WarningHandlerWithContext, f fuzz.Continue) { + func(h *WarningHandlerWithContext, f randfill.Continue) { *h = &fakeWarningHandlerWithContext{} }, // Authentication does not require fuzzer - func(r *AuthProviderConfigPersister, f fuzz.Continue) {}, - func(r *clientcmdapi.AuthProviderConfig, f fuzz.Continue) { + func(r *AuthProviderConfigPersister, f randfill.Continue) {}, + func(r *clientcmdapi.AuthProviderConfig, f randfill.Continue) { r.Config = map[string]string{} }, - func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f fuzz.Continue) { + func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f randfill.Continue) { *r = fakeDialFunc }, - func(r *func(*http.Request) (*url.URL, error), f fuzz.Continue) { + func(r *func(*http.Request) (*url.URL, error), f randfill.Continue) { *r = fakeProxyFunc }, - func(r *runtime.Object, f fuzz.Continue) { + func(r *runtime.Object, f randfill.Continue) { unknown := &runtime.Unknown{} - f.Fuzz(unknown) + f.Fill(unknown) *r = unknown }, ) for i := 0; i < 20; i++ { original := &Config{} - f.Fuzz(original) + f.Fill(original) actual := AnonymousClientConfig(original) expected := *original @@ -414,58 +414,58 @@ func TestAnonymousAuthConfig(t *testing.T) { } func TestCopyConfig(t *testing.T) { - f := fuzz.New().NilChance(0.0).NumElements(1, 1) + f := randfill.New().NilChance(0.0).NumElements(1, 1) f.Funcs( - func(r *runtime.Codec, f fuzz.Continue) { + func(r *runtime.Codec, f randfill.Continue) { codec := &fakeCodec{} - f.Fuzz(codec) + f.Fill(codec) *r = codec }, - func(r *http.RoundTripper, f fuzz.Continue) { + func(r *http.RoundTripper, f randfill.Continue) { roundTripper := &fakeRoundTripper{} - f.Fuzz(roundTripper) + f.Fill(roundTripper) *r = roundTripper }, - func(fn *func(http.RoundTripper) http.RoundTripper, f fuzz.Continue) { + func(fn *func(http.RoundTripper) http.RoundTripper, f randfill.Continue) { *fn = fakeWrapperFunc }, - func(fn *transport.WrapperFunc, f fuzz.Continue) { + func(fn *transport.WrapperFunc, f randfill.Continue) { *fn = fakeWrapperFunc }, - func(r *runtime.NegotiatedSerializer, f fuzz.Continue) { + func(r *runtime.NegotiatedSerializer, f randfill.Continue) { serializer := &fakeNegotiatedSerializer{} - f.Fuzz(serializer) + f.Fill(serializer) *r = serializer }, - func(r *flowcontrol.RateLimiter, f fuzz.Continue) { + func(r *flowcontrol.RateLimiter, f randfill.Continue) { limiter := &fakeLimiter{} - f.Fuzz(limiter) + f.Fill(limiter) *r = limiter }, - func(h *WarningHandler, f fuzz.Continue) { + func(h *WarningHandler, f randfill.Continue) { *h = &fakeWarningHandler{} }, - func(h *WarningHandlerWithContext, f fuzz.Continue) { + func(h *WarningHandlerWithContext, f randfill.Continue) { *h = &fakeWarningHandlerWithContext{} }, - func(r *AuthProviderConfigPersister, f fuzz.Continue) { + func(r *AuthProviderConfigPersister, f randfill.Continue) { *r = fakeAuthProviderConfigPersister{} }, - func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f fuzz.Continue) { + func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f randfill.Continue) { *r = fakeDialFunc }, - func(r *func(*http.Request) (*url.URL, error), f fuzz.Continue) { + func(r *func(*http.Request) (*url.URL, error), f randfill.Continue) { *r = fakeProxyFunc }, - func(r *runtime.Object, f fuzz.Continue) { + func(r *runtime.Object, f randfill.Continue) { unknown := &runtime.Unknown{} - f.Fuzz(unknown) + f.Fill(unknown) *r = unknown }, ) for i := 0; i < 20; i++ { original := &Config{} - f.Fuzz(original) + f.Fill(original) actual := CopyConfig(original) expected := *original diff --git a/staging/src/k8s.io/client-go/rest/exec_test.go b/staging/src/k8s.io/client-go/rest/exec_test.go index 6ab7bcc9730..290b512c2ac 100644 --- a/staging/src/k8s.io/client-go/rest/exec_test.go +++ b/staging/src/k8s.io/client-go/rest/exec_test.go @@ -26,12 +26,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/runtime" clientauthenticationapi "k8s.io/client-go/pkg/apis/clientauthentication" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/client-go/transport" "k8s.io/client-go/util/flowcontrol" + "sigs.k8s.io/randfill" ) func TestConfigToExecCluster(t *testing.T) { @@ -211,60 +211,60 @@ func TestConfigToExecCluster(t *testing.T) { func TestConfigToExecClusterRoundtrip(t *testing.T) { t.Parallel() - f := fuzz.New().NilChance(0.5).NumElements(1, 1) + f := randfill.New().NilChance(0.5).NumElements(1, 1) f.Funcs( - func(r *runtime.Codec, f fuzz.Continue) { + func(r *runtime.Codec, f randfill.Continue) { codec := &fakeCodec{} - f.Fuzz(codec) + f.Fill(codec) *r = codec }, - func(r *http.RoundTripper, f fuzz.Continue) { + func(r *http.RoundTripper, f randfill.Continue) { roundTripper := &fakeRoundTripper{} - f.Fuzz(roundTripper) + f.Fill(roundTripper) *r = roundTripper }, - func(fn *func(http.RoundTripper) http.RoundTripper, f fuzz.Continue) { + func(fn *func(http.RoundTripper) http.RoundTripper, f randfill.Continue) { *fn = fakeWrapperFunc }, - func(fn *transport.WrapperFunc, f fuzz.Continue) { + func(fn *transport.WrapperFunc, f randfill.Continue) { *fn = fakeWrapperFunc }, - func(r *runtime.NegotiatedSerializer, f fuzz.Continue) { + func(r *runtime.NegotiatedSerializer, f randfill.Continue) { serializer := &fakeNegotiatedSerializer{} - f.Fuzz(serializer) + f.Fill(serializer) *r = serializer }, - func(r *flowcontrol.RateLimiter, f fuzz.Continue) { + func(r *flowcontrol.RateLimiter, f randfill.Continue) { limiter := &fakeLimiter{} - f.Fuzz(limiter) + f.Fill(limiter) *r = limiter }, - func(h *WarningHandler, f fuzz.Continue) { + func(h *WarningHandler, f randfill.Continue) { *h = &fakeWarningHandler{} }, - func(h *WarningHandlerWithContext, f fuzz.Continue) { + func(h *WarningHandlerWithContext, f randfill.Continue) { *h = &fakeWarningHandlerWithContext{} }, // Authentication does not require fuzzer - func(r *AuthProviderConfigPersister, f fuzz.Continue) {}, - func(r *clientcmdapi.AuthProviderConfig, f fuzz.Continue) { + func(r *AuthProviderConfigPersister, f randfill.Continue) {}, + func(r *clientcmdapi.AuthProviderConfig, f randfill.Continue) { r.Config = map[string]string{} }, - func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f fuzz.Continue) { + func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f randfill.Continue) { *r = fakeDialFunc }, - func(r *func(*http.Request) (*url.URL, error), f fuzz.Continue) { + func(r *func(*http.Request) (*url.URL, error), f randfill.Continue) { *r = fakeProxyFunc }, - func(r *runtime.Object, f fuzz.Continue) { + func(r *runtime.Object, f randfill.Continue) { unknown := &runtime.Unknown{} - f.Fuzz(unknown) + f.Fill(unknown) *r = unknown }, ) for i := 0; i < 100; i++ { expected := &Config{} - f.Fuzz(expected) + f.Fill(expected) // This is the list of known fields that this roundtrip doesn't care about. We should add new // fields to this list if we don't want to roundtrip them on exec cluster conversion. @@ -347,9 +347,9 @@ func TestConfigToExecClusterRoundtrip(t *testing.T) { func TestExecClusterToConfigRoundtrip(t *testing.T) { t.Parallel() - f := fuzz.New().NilChance(0.5).NumElements(1, 1) + f := randfill.New().NilChance(0.5).NumElements(1, 1) f.Funcs( - func(r *runtime.Object, f fuzz.Continue) { + func(r *runtime.Object, f randfill.Continue) { // We don't expect the clientauthentication.Cluster.Config to show up in the Config that // comes back from the roundtrip, so just set it to nil. *r = nil @@ -357,7 +357,7 @@ func TestExecClusterToConfigRoundtrip(t *testing.T) { ) for i := 0; i < 100; i++ { expected := &clientauthenticationapi.Cluster{} - f.Fuzz(expected) + f.Fill(expected) // Manually set URLs so we don't get an error when parsing these during the roundtrip. if expected.Server != "" { diff --git a/staging/src/k8s.io/client-go/tools/cache/controller_test.go b/staging/src/k8s.io/client-go/tools/cache/controller_test.go index 9067fc15feb..d76cc634de6 100644 --- a/staging/src/k8s.io/client-go/tools/cache/controller_test.go +++ b/staging/src/k8s.io/client-go/tools/cache/controller_test.go @@ -35,7 +35,7 @@ import ( fcache "k8s.io/client-go/tools/cache/testing" "k8s.io/klog/v2/ktesting" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func Example() { @@ -252,12 +252,12 @@ func TestHammerController(t *testing.T) { // Let's add a few objects to the source. currentNames := sets.String{} rs := rand.NewSource(rand.Int63()) - f := fuzz.New().NilChance(.5).NumElements(0, 2).RandSource(rs) + f := randfill.New().NilChance(.5).NumElements(0, 2).RandSource(rs) for i := 0; i < 100; i++ { var name string var isNew bool if currentNames.Len() == 0 || rand.Intn(3) == 1 { - f.Fuzz(&name) + f.Fill(&name) isNew = true } else { l := currentNames.List() @@ -265,7 +265,7 @@ func TestHammerController(t *testing.T) { } pod := &v1.Pod{} - f.Fuzz(pod) + f.Fill(pod) pod.ObjectMeta.Name = name pod.ObjectMeta.Namespace = "default" // Add, update, or delete randomly. diff --git a/staging/src/k8s.io/cloud-provider/go.mod b/staging/src/k8s.io/cloud-provider/go.mod index 3e8a019f53b..cb6715a961b 100644 --- a/staging/src/k8s.io/cloud-provider/go.mod +++ b/staging/src/k8s.io/cloud-provider/go.mod @@ -49,7 +49,6 @@ require ( github.com/google/btree v1.1.3 // indirect github.com/google/cel-go v0.23.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect @@ -103,10 +102,11 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/kms v0.0.0 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/cloud-provider/go.sum b/staging/src/k8s.io/cloud-provider/go.sum index 31292d5e5ac..fe0bdda3511 100644 --- a/staging/src/k8s.io/cloud-provider/go.sum +++ b/staging/src/k8s.io/cloud-provider/go.sum @@ -80,8 +80,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -305,15 +303,18 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/cluster-bootstrap/go.mod b/staging/src/k8s.io/cluster-bootstrap/go.mod index 848bbc948dd..514f14c49fe 100644 --- a/staging/src/k8s.io/cluster-bootstrap/go.mod +++ b/staging/src/k8s.io/cluster-bootstrap/go.mod @@ -19,7 +19,6 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/text v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -33,7 +32,8 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/cluster-bootstrap/go.sum b/staging/src/k8s.io/cluster-bootstrap/go.sum index 4349b1ed426..e36e98d3d5e 100644 --- a/staging/src/k8s.io/cluster-bootstrap/go.sum +++ b/staging/src/k8s.io/cluster-bootstrap/go.sum @@ -17,8 +17,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -105,12 +103,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interface_fuzzer.go b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interface_fuzzer.go index 11fdb84bff8..d6f960f1ddf 100644 --- a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interface_fuzzer.go +++ b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interface_fuzzer.go @@ -17,7 +17,7 @@ limitations under the License. package outputtests import ( - "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/code-generator/cmd/deepcopy-gen/output_tests/aliases" "k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interfaces" @@ -27,49 +27,49 @@ import ( // JSON deepcopy does not work with it. // TODO: test also interface deepcopy var interfaceFuzzers = []interface{}{ - func(s *aliases.AliasAliasInterface, c fuzz.Continue) { - if c.RandBool() { + func(s *aliases.AliasAliasInterface, c randfill.Continue) { + if c.Bool() { *s = nil } else { *s = &aliasAliasInterfaceInstance{X: c.Int()} } }, - func(s *aliases.AliasInterface, c fuzz.Continue) { - if c.RandBool() { + func(s *aliases.AliasInterface, c randfill.Continue) { + if c.Bool() { *s = nil } else { *s = &aliasAliasInterfaceInstance{X: c.Int()} } }, - func(s *aliases.Interface, c fuzz.Continue) { - if c.RandBool() { + func(s *aliases.Interface, c randfill.Continue) { + if c.Bool() { *s = nil } else { *s = &aliasAliasInterfaceInstance{X: c.Int()} } }, - func(s *aliases.AliasInterfaceMap, c fuzz.Continue) { - if c.RandBool() { + func(s *aliases.AliasInterfaceMap, c randfill.Continue) { + if c.Bool() { *s = nil } else { *s = make(aliases.AliasInterfaceMap) for i := 0; i < c.Intn(3); i++ { - if c.RandBool() { - (*s)[c.RandString()] = nil + if c.Bool() { + (*s)[c.String(0)] = nil } else { - (*s)[c.RandString()] = &aliasAliasInterfaceInstance{X: c.Int()} + (*s)[c.String(0)] = &aliasAliasInterfaceInstance{X: c.Int()} } } } }, - func(s *aliases.AliasInterfaceSlice, c fuzz.Continue) { - if c.RandBool() { + func(s *aliases.AliasInterfaceSlice, c randfill.Continue) { + if c.Bool() { *s = nil } else { *s = make(aliases.AliasInterfaceSlice, 0) for i := 0; i < c.Intn(3); i++ { - if c.RandBool() { + if c.Bool() { *s = append(*s, nil) } else { *s = append(*s, &aliasAliasInterfaceInstance{X: c.Int()}) @@ -77,8 +77,8 @@ var interfaceFuzzers = []interface{}{ } } }, - func(s *interfaces.Inner, c fuzz.Continue) { - if c.RandBool() { + func(s *interfaces.Inner, c randfill.Continue) { + if c.Bool() { *s = nil } else { *s = &interfacesInnerInstance{X: c.Float64()} diff --git a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/output_test.go b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/output_test.go index 0bd0d90bf53..aab3b3367bf 100644 --- a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/output_test.go +++ b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/output_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/apimachinery/pkg/util/dump" "k8s.io/code-generator/cmd/deepcopy-gen/output_tests/aliases" @@ -44,7 +44,7 @@ func TestWithValueFuzzer(t *testing.T) { structs.Ttest{}, } - fuzzer := fuzz.New() + fuzzer := randfill.New() fuzzer.NilChance(0.5) fuzzer.NumElements(0, 2) fuzzer.Funcs(interfaceFuzzers...) @@ -55,7 +55,7 @@ func TestWithValueFuzzer(t *testing.T) { for i := 0; i < N; i++ { original := reflect.New(reflect.TypeOf(test)).Interface() - fuzzer.Fuzz(original) + fuzzer.Fill(original) reflectCopy := ReflectDeepCopy(original) @@ -149,7 +149,7 @@ func BenchmarkReflectDeepCopy(b *testing.B) { }, } - fuzzer := fuzz.New() + fuzzer := randfill.New() fuzzer.NilChance(0.5) fuzzer.NumElements(0, 2) fuzzer.Funcs(interfaceFuzzers...) diff --git a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/wholepkg/deepcopy_test.go b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/wholepkg/deepcopy_test.go index b5089d6d408..0f66a1d0d04 100644 --- a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/wholepkg/deepcopy_test.go +++ b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/wholepkg/deepcopy_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" ) func TestDeepCopyPrimitives(t *testing.T) { @@ -31,9 +31,9 @@ func TestDeepCopyPrimitives(t *testing.T) { t.Errorf("objects should be equal to start, but are not") } - fuzzer := fuzz.New() - fuzzer.Fuzz(&x) - fuzzer.Fuzz(&y) + fuzzer := randfill.New() + fuzzer.Fill(&x) + fuzzer.Fill(&y) if reflect.DeepEqual(&x, &y) { t.Errorf("objects should not be equal, but are") @@ -53,14 +53,14 @@ func TestDeepCopyInterfaceFields(t *testing.T) { t.Errorf("objects should be equal to start, but are not") } - fuzzer := fuzz.New() + fuzzer := randfill.New() obj := StructExplicitObject{} - fuzzer.Fuzz(&obj) + fuzzer.Fill(&obj) x.ObjectField = &obj sel := StructExplicitSelectorExplicitObject{} - fuzzer.Fuzz(&sel) + fuzzer.Fill(&sel) x.SelectorField = &sel if reflect.DeepEqual(&x, &y) { @@ -115,8 +115,8 @@ func TestInterfaceTypes(t *testing.T) { func TestInterfaceDeepCopy(t *testing.T) { x := StructExplicitObject{} - fuzzer := fuzz.New() - fuzzer.Fuzz(&x) + fuzzer := randfill.New() + fuzzer.Fill(&x) yObj := x.DeepCopyObject() y, ok := yObj.(*StructExplicitObject) @@ -131,8 +131,8 @@ func TestInterfaceDeepCopy(t *testing.T) { func TestInterfaceNonPointerDeepCopy(t *testing.T) { x := StructNonPointerExplicitObject{} - fuzzer := fuzz.New() - fuzzer.Fuzz(&x) + fuzzer := randfill.New() + fuzzer.Fill(&x) yObj := x.DeepCopyObject() y, ok := yObj.(StructNonPointerExplicitObject) diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/cross_pkg/doc.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/cross_pkg/doc.go index 908748df620..610bba2be95 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/cross_pkg/doc.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/cross_pkg/doc.go @@ -123,7 +123,7 @@ type T1 struct { } // TODO: the validateFalse test fixture doesn't handle map and slice types, and -// fixing it requires fixing gofuzz. That is a tomorrow problem. For now, the +// fixing it requires fixing randfill. That is a tomorrow problem. For now, the // following types have been tested to fail without +k8s:opaqueType. /* diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/tags/opaque/doc.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/tags/opaque/doc.go index d89c87f2aeb..1188d8e4a0c 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/tags/opaque/doc.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/output_tests/tags/opaque/doc.go @@ -124,7 +124,7 @@ type OtherStruct struct { type OtherString string // TODO: the validateFalse test fixture doesn't handle map and slice types, and -// fixing it requires fixing gofuzz. That is a tomorrow problem. For now, the +// fixing it requires fixing randfill. That is a tomorrow problem. For now, the // following types have been tested to generate correct code with // +k8s:opaqueType. diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/testscheme/testscheme.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/testscheme/testscheme.go index b31f85a59bd..60c92997e10 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/testscheme/testscheme.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/testscheme/testscheme.go @@ -35,11 +35,11 @@ import ( "github.com/google/go-cmp/cmp" // nolint:depguard // this package provides test utilities "github.com/google/go-cmp/cmp/cmpopts" // nolint:depguard // this package provides test utilities - fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/operation" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation/field" + "sigs.k8s.io/randfill" ) // Scheme is similar to runtime.Scheme, but for validation testing purposes. Scheme only supports validation, @@ -221,15 +221,15 @@ func (s *ValidationTestBuilder) ValidateFixtures() { } } -func fuzzer() *fuzz.Fuzzer { +func randfiller() *randfill.Filler { // Ensure that lists and maps are not empty and use a deterministic seed. - return fuzz.New().NilChance(0.0).NumElements(2, 2).RandSource(rand.NewSource(0)) + return randfill.New().NilChance(0.0).NumElements(2, 2).RandSource(rand.NewSource(0)) } -// ValueFuzzed automatically populates the given value using a deterministic fuzzer. -// The fuzzer sets pointers to values and always includes a two map keys and slice elements. +// ValueFuzzed automatically populates the given value using a deterministic filler. +// The filler sets pointers to values and always includes a two map keys and slice elements. func (s *ValidationTestBuilder) ValueFuzzed(value any) *ValidationTester { - fuzzer().Fuzz(value) + randfiller().Fill(value) return &ValidationTester{ValidationTestBuilder: s, value: value} } @@ -257,10 +257,10 @@ func (v *ValidationTester) OldValue(oldValue any) *ValidationTester { return v } -// OldValueFuzzed automatically populates the given value using a deterministic fuzzer. -// The fuzzer sets pointers to values and always includes a two map keys and slice elements. +// OldValueFuzzed automatically populates the given value using a deterministic filler. +// The filler sets pointers to values and always includes a two map keys and slice elements. func (v *ValidationTester) OldValueFuzzed(oldValue any) *ValidationTester { - fuzzer().Fuzz(oldValue) + randfiller().Fill(oldValue) v.oldValue = oldValue return v } diff --git a/staging/src/k8s.io/code-generator/examples/go.mod b/staging/src/k8s.io/code-generator/examples/go.mod index a1067d351c4..648fa34b9ad 100644 --- a/staging/src/k8s.io/code-generator/examples/go.mod +++ b/staging/src/k8s.io/code-generator/examples/go.mod @@ -11,8 +11,8 @@ require ( k8s.io/apimachinery v0.0.0 k8s.io/client-go v0.0.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 ) require ( @@ -26,7 +26,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -48,6 +47,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/code-generator/examples/go.sum b/staging/src/k8s.io/code-generator/examples/go.sum index 7ce8b281ff6..8ef444c5aad 100644 --- a/staging/src/k8s.io/code-generator/examples/go.sum +++ b/staging/src/k8s.io/code-generator/examples/go.sum @@ -27,8 +27,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -137,13 +135,16 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/code-generator/go.mod b/staging/src/k8s.io/code-generator/go.mod index d9b5c02a6e8..987f72d504e 100644 --- a/staging/src/k8s.io/code-generator/go.mod +++ b/staging/src/k8s.io/code-generator/go.mod @@ -10,14 +10,14 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/google/gnostic-models v0.6.9 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/text v0.22.0 k8s.io/apimachinery v0.0.0 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 + sigs.k8s.io/randfill v1.0.0 sigs.k8s.io/yaml v1.4.0 ) @@ -44,7 +44,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect ) replace k8s.io/apimachinery => ../apimachinery diff --git a/staging/src/k8s.io/code-generator/go.sum b/staging/src/k8s.io/code-generator/go.sum index c48244764fc..26e1e4e4d65 100644 --- a/staging/src/k8s.io/code-generator/go.sum +++ b/staging/src/k8s.io/code-generator/go.sum @@ -30,8 +30,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -140,13 +138,16 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/component-base/go.mod b/staging/src/k8s.io/component-base/go.mod index 707fb22e7f2..9348be037b0 100644 --- a/staging/src/k8s.io/component-base/go.mod +++ b/staging/src/k8s.io/component-base/go.mod @@ -50,7 +50,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -81,8 +80,9 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.0.0 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect ) replace ( diff --git a/staging/src/k8s.io/component-base/go.sum b/staging/src/k8s.io/component-base/go.sum index 89331bd6c9f..9c6542a63a0 100644 --- a/staging/src/k8s.io/component-base/go.sum +++ b/staging/src/k8s.io/component-base/go.sum @@ -61,8 +61,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -237,13 +235,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/component-helpers/go.mod b/staging/src/k8s.io/component-helpers/go.mod index 39204606ea5..e1095c8572a 100644 --- a/staging/src/k8s.io/component-helpers/go.mod +++ b/staging/src/k8s.io/component-helpers/go.mod @@ -26,7 +26,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -47,9 +46,10 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/component-helpers/go.sum b/staging/src/k8s.io/component-helpers/go.sum index 1db5ecf3330..11be6b7278d 100644 --- a/staging/src/k8s.io/component-helpers/go.sum +++ b/staging/src/k8s.io/component-helpers/go.sum @@ -31,8 +31,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -150,13 +148,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/controller-manager/go.mod b/staging/src/k8s.io/controller-manager/go.mod index 560f2bef793..320f186fe2e 100644 --- a/staging/src/k8s.io/controller-manager/go.mod +++ b/staging/src/k8s.io/controller-manager/go.mod @@ -44,7 +44,6 @@ require ( github.com/google/cel-go v0.23.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect @@ -95,10 +94,11 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/controller-manager/go.sum b/staging/src/k8s.io/controller-manager/go.sum index 2b8784980f7..ab613fc8d74 100644 --- a/staging/src/k8s.io/controller-manager/go.sum +++ b/staging/src/k8s.io/controller-manager/go.sum @@ -77,8 +77,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -300,15 +298,18 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/cri-client/go.mod b/staging/src/k8s.io/cri-client/go.mod index 5f7f66a30e2..00a30ba344c 100644 --- a/staging/src/k8s.io/cri-client/go.mod +++ b/staging/src/k8s.io/cri-client/go.mod @@ -40,7 +40,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -72,9 +71,10 @@ require ( google.golang.org/protobuf v1.36.5 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/cri-client/go.sum b/staging/src/k8s.io/cri-client/go.sum index 38228857ff8..ab5bcf57b2c 100644 --- a/staging/src/k8s.io/cri-client/go.sum +++ b/staging/src/k8s.io/cri-client/go.sum @@ -59,8 +59,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -223,13 +221,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/csi-translation-lib/go.mod b/staging/src/k8s.io/csi-translation-lib/go.mod index 52561bc0830..736898edaa1 100644 --- a/staging/src/k8s.io/csi-translation-lib/go.mod +++ b/staging/src/k8s.io/csi-translation-lib/go.mod @@ -18,7 +18,6 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/text v0.2.0 // indirect @@ -32,7 +31,8 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/csi-translation-lib/go.sum b/staging/src/k8s.io/csi-translation-lib/go.sum index b0469b6cc75..072bb5fc437 100644 --- a/staging/src/k8s.io/csi-translation-lib/go.sum +++ b/staging/src/k8s.io/csi-translation-lib/go.sum @@ -17,8 +17,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -103,12 +101,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/dynamic-resource-allocation/go.mod b/staging/src/k8s.io/dynamic-resource-allocation/go.mod index 8546f7cf508..b152fb0bbfb 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/go.mod +++ b/staging/src/k8s.io/dynamic-resource-allocation/go.mod @@ -37,7 +37,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -73,9 +72,10 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/component-base v0.0.0 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/dynamic-resource-allocation/go.sum b/staging/src/k8s.io/dynamic-resource-allocation/go.sum index 1c50f45949a..991e9276662 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/go.sum +++ b/staging/src/k8s.io/dynamic-resource-allocation/go.sum @@ -63,8 +63,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -252,14 +250,17 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/endpointslice/go.mod b/staging/src/k8s.io/endpointslice/go.mod index 11a54571e8b..8c038d6227c 100644 --- a/staging/src/k8s.io/endpointslice/go.mod +++ b/staging/src/k8s.io/endpointslice/go.mod @@ -30,7 +30,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -59,9 +58,10 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/endpointslice/go.sum b/staging/src/k8s.io/endpointslice/go.sum index e5a6976ccdc..1b039e3b1f7 100644 --- a/staging/src/k8s.io/endpointslice/go.sum +++ b/staging/src/k8s.io/endpointslice/go.sum @@ -44,8 +44,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -200,13 +198,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/kube-aggregator/go.mod b/staging/src/k8s.io/kube-aggregator/go.mod index 4c38620ec4b..8e7eeed0318 100644 --- a/staging/src/k8s.io/kube-aggregator/go.mod +++ b/staging/src/k8s.io/kube-aggregator/go.mod @@ -10,7 +10,6 @@ require ( github.com/emicklei/go-restful/v3 v3.11.0 github.com/gogo/protobuf v1.3.2 github.com/google/go-cmp v0.7.0 - github.com/google/gofuzz v1.2.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 @@ -25,9 +24,10 @@ require ( k8s.io/code-generator v0.0.0 k8s.io/component-base v0.0.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 ) require ( diff --git a/staging/src/k8s.io/kube-aggregator/go.sum b/staging/src/k8s.io/kube-aggregator/go.sum index 2d0e4eac8e8..dfba883c2e9 100644 --- a/staging/src/k8s.io/kube-aggregator/go.sum +++ b/staging/src/k8s.io/kube-aggregator/go.sum @@ -78,8 +78,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -307,15 +305,18 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery_test.go b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery_test.go index 93a8409f9cc..3c8f17b8373 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery_test.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery_test.go @@ -30,8 +30,8 @@ import ( "time" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/require" + "sigs.k8s.io/randfill" apidiscoveryv2 "k8s.io/api/apidiscovery/v2" apidiscoveryv2beta1 "k8s.io/api/apidiscovery/v2beta1" @@ -1008,16 +1008,16 @@ func TestNotModified(t *testing.T) { // copied from staging/src/k8s.io/apiserver/pkg/endpoints/discovery/v2/handler_test.go func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv2.APIGroupDiscoveryList { - fuzzer := fuzz.NewWithSeed(seed) + fuzzer := randfill.NewWithSeed(seed) fuzzer.NumElements(atLeastNumGroups, maxNumGroups) fuzzer.NilChance(0) - fuzzer.Funcs(func(o *apidiscoveryv2.APIGroupDiscovery, c fuzz.Continue) { - c.FuzzNoCustom(o) + fuzzer.Funcs(func(o *apidiscoveryv2.APIGroupDiscovery, c randfill.Continue) { + c.FillNoCustom(o) // The ResourceManager will just not serve the group if its versions // list is empty atLeastOne := apidiscoveryv2.APIVersionDiscovery{} - c.Fuzz(&atLeastOne) + c.Fill(&atLeastOne) o.Versions = append(o.Versions, atLeastOne) // clear invalid fuzzed values @@ -1032,7 +1032,7 @@ func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv }) var apis []apidiscoveryv2.APIGroupDiscovery - fuzzer.Fuzz(&apis) + fuzzer.Fill(&apis) return apidiscoveryv2.APIGroupDiscoveryList{ TypeMeta: metav1.TypeMeta{ diff --git a/staging/src/k8s.io/kube-controller-manager/go.mod b/staging/src/k8s.io/kube-controller-manager/go.mod index b88f0ac20cf..0cb6bd87b79 100644 --- a/staging/src/k8s.io/kube-controller-manager/go.mod +++ b/staging/src/k8s.io/kube-controller-manager/go.mod @@ -16,7 +16,6 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -30,7 +29,8 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/kube-controller-manager/go.sum b/staging/src/k8s.io/kube-controller-manager/go.sum index 9e8a11688b3..0e4f01ee564 100644 --- a/staging/src/k8s.io/kube-controller-manager/go.sum +++ b/staging/src/k8s.io/kube-controller-manager/go.sum @@ -35,8 +35,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI= @@ -157,13 +155,16 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/kube-proxy/go.mod b/staging/src/k8s.io/kube-proxy/go.mod index ccddeceaa3f..12e228df9ee 100644 --- a/staging/src/k8s.io/kube-proxy/go.mod +++ b/staging/src/k8s.io/kube-proxy/go.mod @@ -19,7 +19,6 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -42,7 +41,8 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/kube-proxy/go.sum b/staging/src/k8s.io/kube-proxy/go.sum index f30b2ad35ef..7b7c9052a4f 100644 --- a/staging/src/k8s.io/kube-proxy/go.sum +++ b/staging/src/k8s.io/kube-proxy/go.sum @@ -32,8 +32,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -161,12 +159,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/kube-scheduler/go.mod b/staging/src/k8s.io/kube-scheduler/go.mod index a2d8b25c0b9..9e34c506309 100644 --- a/staging/src/k8s.io/kube-scheduler/go.mod +++ b/staging/src/k8s.io/kube-scheduler/go.mod @@ -18,7 +18,6 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/text v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -30,7 +29,8 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect ) replace ( diff --git a/staging/src/k8s.io/kube-scheduler/go.sum b/staging/src/k8s.io/kube-scheduler/go.sum index 971e5faab93..5ffb06649cb 100644 --- a/staging/src/k8s.io/kube-scheduler/go.sum +++ b/staging/src/k8s.io/kube-scheduler/go.sum @@ -26,8 +26,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -135,12 +133,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/kubectl/go.mod b/staging/src/k8s.io/kubectl/go.mod index 49f246ed752..453250225fe 100644 --- a/staging/src/k8s.io/kubectl/go.mod +++ b/staging/src/k8s.io/kubectl/go.mod @@ -36,13 +36,13 @@ require ( k8s.io/component-base v0.0.0 k8s.io/component-helpers v0.0.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/metrics v0.0.0 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 sigs.k8s.io/kustomize/kustomize/v5 v5.6.0 sigs.k8s.io/kustomize/kyaml v0.19.0 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 sigs.k8s.io/yaml v1.4.0 ) @@ -59,7 +59,6 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/btree v1.1.3 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect @@ -91,6 +90,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/kustomize/api v0.19.0 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect ) replace ( diff --git a/staging/src/k8s.io/kubectl/go.sum b/staging/src/k8s.io/kubectl/go.sum index 582939b3a61..9d7037ed5d9 100644 --- a/staging/src/k8s.io/kubectl/go.sum +++ b/staging/src/k8s.io/kubectl/go.sum @@ -59,8 +59,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -236,8 +234,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= @@ -249,7 +247,10 @@ sigs.k8s.io/kustomize/kustomize/v5 v5.6.0 h1:MWtRRDWCwQEeW2rnJTqJMuV6Agy56P53Skb sigs.k8s.io/kustomize/kustomize/v5 v5.6.0/go.mod h1:XuuZiQF7WdcvZzEYyNww9A0p3LazCKeJmCjeycN8e1I= sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA= sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/kubelet/go.mod b/staging/src/k8s.io/kubelet/go.mod index d097835fb7e..d995d8344e4 100644 --- a/staging/src/k8s.io/kubelet/go.mod +++ b/staging/src/k8s.io/kubelet/go.mod @@ -29,7 +29,6 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -59,7 +58,8 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/kubelet/go.sum b/staging/src/k8s.io/kubelet/go.sum index 3085463a70b..2a73e9609f1 100644 --- a/staging/src/k8s.io/kubelet/go.sum +++ b/staging/src/k8s.io/kubelet/go.sum @@ -56,8 +56,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -229,14 +227,17 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/metrics/go.mod b/staging/src/k8s.io/metrics/go.mod index 9d2c22cf40a..a8a05b33a8d 100644 --- a/staging/src/k8s.io/metrics/go.mod +++ b/staging/src/k8s.io/metrics/go.mod @@ -25,7 +25,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -52,10 +51,11 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/metrics/go.sum b/staging/src/k8s.io/metrics/go.sum index 396a6b32705..d706703a309 100644 --- a/staging/src/k8s.io/metrics/go.sum +++ b/staging/src/k8s.io/metrics/go.sum @@ -31,8 +31,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -154,13 +152,16 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/pod-security-admission/go.mod b/staging/src/k8s.io/pod-security-admission/go.mod index f634a5da851..c540310b97f 100644 --- a/staging/src/k8s.io/pod-security-admission/go.mod +++ b/staging/src/k8s.io/pod-security-admission/go.mod @@ -47,7 +47,6 @@ require ( github.com/google/btree v1.1.3 // indirect github.com/google/cel-go v0.23.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect @@ -100,10 +99,11 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/kms v0.0.0 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect ) replace ( diff --git a/staging/src/k8s.io/pod-security-admission/go.sum b/staging/src/k8s.io/pod-security-admission/go.sum index 2b8784980f7..ab613fc8d74 100644 --- a/staging/src/k8s.io/pod-security-admission/go.sum +++ b/staging/src/k8s.io/pod-security-admission/go.sum @@ -77,8 +77,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -300,15 +298,18 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/sample-apiserver/go.mod b/staging/src/k8s.io/sample-apiserver/go.mod index fcb3d4d6440..20b082e53cd 100644 --- a/staging/src/k8s.io/sample-apiserver/go.mod +++ b/staging/src/k8s.io/sample-apiserver/go.mod @@ -7,7 +7,6 @@ go 1.24.0 godebug default=go1.24 require ( - github.com/google/gofuzz v1.2.0 github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.10.0 k8s.io/apimachinery v0.0.0 @@ -15,9 +14,10 @@ require ( k8s.io/client-go v0.0.0 k8s.io/code-generator v0.0.0 k8s.io/component-base v0.0.0 - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 + sigs.k8s.io/randfill v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 ) require ( diff --git a/staging/src/k8s.io/sample-apiserver/go.sum b/staging/src/k8s.io/sample-apiserver/go.sum index d32dc11ed53..5f9b6c30564 100644 --- a/staging/src/k8s.io/sample-apiserver/go.sum +++ b/staging/src/k8s.io/sample-apiserver/go.sum @@ -77,8 +77,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -304,15 +302,18 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/fuzzer/fuzzer.go b/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/fuzzer/fuzzer.go index 9278a59f580..62327a6cd03 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/fuzzer/fuzzer.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/fuzzer/fuzzer.go @@ -17,8 +17,8 @@ limitations under the License. package fuzzer import ( - fuzz "github.com/google/gofuzz" "k8s.io/sample-apiserver/pkg/apis/wardle" + "sigs.k8s.io/randfill" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" ) @@ -26,8 +26,8 @@ import ( // Funcs returns the fuzzer functions for the apps api group. var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(s *wardle.FlunderSpec, c fuzz.Continue) { - c.FuzzNoCustom(s) // fuzz self without calling this function again + func(s *wardle.FlunderSpec, c randfill.Continue) { + c.FillNoCustom(s) // fuzz self without calling this function again if len(s.FlunderReference) != 0 && len(s.FischerReference) != 0 { s.FischerReference = "" diff --git a/staging/src/k8s.io/sample-cli-plugin/go.mod b/staging/src/k8s.io/sample-cli-plugin/go.mod index fb83496efe6..ddb9259cb19 100644 --- a/staging/src/k8s.io/sample-cli-plugin/go.mod +++ b/staging/src/k8s.io/sample-cli-plugin/go.mod @@ -28,7 +28,6 @@ require ( github.com/google/btree v1.1.3 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect @@ -60,12 +59,13 @@ require ( k8s.io/api v0.0.0 // indirect k8s.io/apimachinery v0.0.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect sigs.k8s.io/kustomize/api v0.19.0 // indirect sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/sample-cli-plugin/go.sum b/staging/src/k8s.io/sample-cli-plugin/go.sum index 81aed753ae6..8c76cae4044 100644 --- a/staging/src/k8s.io/sample-cli-plugin/go.sum +++ b/staging/src/k8s.io/sample-cli-plugin/go.sum @@ -41,8 +41,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -182,8 +180,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= @@ -192,7 +190,10 @@ sigs.k8s.io/kustomize/api v0.19.0 h1:F+2HB2mU1MSiR9Hp1NEgoU2q9ItNOaBJl0I4Dlus5SQ sigs.k8s.io/kustomize/api v0.19.0/go.mod h1:/BbwnivGVcBh1r+8m3tH1VNxJmHSk1PzP5fkP6lbL1o= sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA= sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/staging/src/k8s.io/sample-controller/go.mod b/staging/src/k8s.io/sample-controller/go.mod index 8d385a33ce7..194adbe4063 100644 --- a/staging/src/k8s.io/sample-controller/go.mod +++ b/staging/src/k8s.io/sample-controller/go.mod @@ -26,7 +26,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -50,10 +49,11 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 // indirect - k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/staging/src/k8s.io/sample-controller/go.sum b/staging/src/k8s.io/sample-controller/go.sum index 31bae1c061b..145a0956d98 100644 --- a/staging/src/k8s.io/sample-controller/go.sum +++ b/staging/src/k8s.io/sample-controller/go.sum @@ -31,8 +31,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -155,13 +153,16 @@ k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1 k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= -k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 h1:t0huyHnz6HsokckRxAF1bY0cqPFwzINKCL7yltEjZQc= +k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/test/e2e/framework/.import-restrictions b/test/e2e/framework/.import-restrictions index d5f497667bb..fc52e328da6 100644 --- a/test/e2e/framework/.import-restrictions +++ b/test/e2e/framework/.import-restrictions @@ -46,7 +46,6 @@ rules: "github.com/google/gnostic-models/openapiv3", "github.com/google/go-cmp/cmp", "github.com/google/go-cmp/cmp/cmpopts", - "github.com/google/gofuzz", "github.com/google/uuid", "github.com/imdario/mergo", "github.com/prometheus/client_golang/", diff --git a/test/images/agnhost/webhook/convert_test.go b/test/images/agnhost/webhook/convert_test.go index 9c8143d41f6..f2a5c5558f0 100644 --- a/test/images/agnhost/webhook/convert_test.go +++ b/test/images/agnhost/webhook/convert_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" v1 "k8s.io/api/admission/v1" "k8s.io/api/admission/v1beta1" @@ -38,7 +38,7 @@ func TestConvertAdmissionRequestToV1(t *testing.T) { for i := 0; i < 100; i++ { t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) { orig := &v1beta1.AdmissionRequest{} - f.Fuzz(orig) + f.Fill(orig) converted := convertAdmissionRequestToV1(orig) rt := convertAdmissionRequestToV1beta1(converted) if !reflect.DeepEqual(orig, rt) { @@ -49,11 +49,11 @@ func TestConvertAdmissionRequestToV1(t *testing.T) { } func TestConvertAdmissionResponseToV1beta1(t *testing.T) { - f := fuzz.New() + f := randfill.New() for i := 0; i < 100; i++ { t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) { orig := &v1.AdmissionResponse{} - f.Fuzz(orig) + f.Fill(orig) converted := convertAdmissionResponseToV1beta1(orig) rt := convertAdmissionResponseToV1(converted) if !reflect.DeepEqual(orig, rt) { diff --git a/test/integration/apiserver/timestamp_transformer_test.go b/test/integration/apiserver/timestamp_transformer_test.go index f5398d4d37a..210662f99e6 100644 --- a/test/integration/apiserver/timestamp_transformer_test.go +++ b/test/integration/apiserver/timestamp_transformer_test.go @@ -59,11 +59,11 @@ func doBench(b *testing.B, useUnstructured bool, shortCircuit bool) { fuzzer.MaxDepth(1000).NilChance(0.2).NumElements(2, 15) pod := &v1.Pod{} - fuzzer.Fuzz(pod) + fuzzer.Fill(pod) fuzzer.NilChance(0.2).NumElements(10, 100).MaxDepth(10) deployment := &v1.Endpoints{} - fuzzer.Fuzz(deployment) + fuzzer.Fill(deployment) bts, err := json.Marshal(deployment) require.NoError(b, err) diff --git a/vendor/github.com/google/gofuzz/.travis.yml b/vendor/github.com/google/gofuzz/.travis.yml deleted file mode 100644 index 061d72ae079..00000000000 --- a/vendor/github.com/google/gofuzz/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: go - -go: - - 1.11.x - - 1.12.x - - 1.13.x - - master - -script: - - go test -cover diff --git a/vendor/github.com/google/gofuzz/CONTRIBUTING.md b/vendor/github.com/google/gofuzz/CONTRIBUTING.md deleted file mode 100644 index 97c1b34fd5e..00000000000 --- a/vendor/github.com/google/gofuzz/CONTRIBUTING.md +++ /dev/null @@ -1,67 +0,0 @@ -# How to contribute # - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - - -## Contributor License Agreement ## - -Contributions to any Google project must be accompanied by a Contributor -License Agreement. This is not a copyright **assignment**, it simply gives -Google permission to use and redistribute your contributions as part of the -project. - - * If you are an individual writing original source code and you're sure you - own the intellectual property, then you'll need to sign an [individual - CLA][]. - - * If you work for a company that wants to allow you to contribute your work, - then you'll need to sign a [corporate CLA][]. - -You generally only need to submit a CLA once, so if you've already submitted -one (even if it was for a different project), you probably don't need to do it -again. - -[individual CLA]: https://developers.google.com/open-source/cla/individual -[corporate CLA]: https://developers.google.com/open-source/cla/corporate - - -## Submitting a patch ## - - 1. It's generally best to start by opening a new issue describing the bug or - feature you're intending to fix. Even if you think it's relatively minor, - it's helpful to know what people are working on. Mention in the initial - issue that you are planning to work on that bug or feature so that it can - be assigned to you. - - 1. Follow the normal process of [forking][] the project, and setup a new - branch to work in. It's important that each group of changes be done in - separate branches in order to ensure that a pull request only includes the - commits related to that bug or feature. - - 1. Go makes it very simple to ensure properly formatted code, so always run - `go fmt` on your code before committing it. You should also run - [golint][] over your code. As noted in the [golint readme][], it's not - strictly necessary that your code be completely "lint-free", but this will - help you find common style issues. - - 1. Any significant changes should almost always be accompanied by tests. The - project already has good test coverage, so look at some of the existing - tests if you're unsure how to go about it. [gocov][] and [gocov-html][] - are invaluable tools for seeing which parts of your code aren't being - exercised by your tests. - - 1. Do your best to have [well-formed commit messages][] for each change. - This provides consistency throughout the project, and ensures that commit - messages are able to be formatted properly by various git tools. - - 1. Finally, push the commits to your fork and submit a [pull request][]. - -[forking]: https://help.github.com/articles/fork-a-repo -[golint]: https://github.com/golang/lint -[golint readme]: https://github.com/golang/lint/blob/master/README -[gocov]: https://github.com/axw/gocov -[gocov-html]: https://github.com/matm/gocov-html -[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html -[squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits -[pull request]: https://help.github.com/articles/creating-a-pull-request diff --git a/vendor/github.com/google/gofuzz/doc.go b/vendor/github.com/google/gofuzz/doc.go deleted file mode 100644 index 9f9956d4a64..00000000000 --- a/vendor/github.com/google/gofuzz/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2014 Google Inc. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package fuzz is a library for populating go objects with random values. -package fuzz diff --git a/vendor/github.com/google/gofuzz/fuzz.go b/vendor/github.com/google/gofuzz/fuzz.go deleted file mode 100644 index 761520a8cee..00000000000 --- a/vendor/github.com/google/gofuzz/fuzz.go +++ /dev/null @@ -1,605 +0,0 @@ -/* -Copyright 2014 Google Inc. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fuzz - -import ( - "fmt" - "math/rand" - "reflect" - "regexp" - "time" - - "github.com/google/gofuzz/bytesource" - "strings" -) - -// fuzzFuncMap is a map from a type to a fuzzFunc that handles that type. -type fuzzFuncMap map[reflect.Type]reflect.Value - -// Fuzzer knows how to fill any object with random fields. -type Fuzzer struct { - fuzzFuncs fuzzFuncMap - defaultFuzzFuncs fuzzFuncMap - r *rand.Rand - nilChance float64 - minElements int - maxElements int - maxDepth int - skipFieldPatterns []*regexp.Regexp -} - -// New returns a new Fuzzer. Customize your Fuzzer further by calling Funcs, -// RandSource, NilChance, or NumElements in any order. -func New() *Fuzzer { - return NewWithSeed(time.Now().UnixNano()) -} - -func NewWithSeed(seed int64) *Fuzzer { - f := &Fuzzer{ - defaultFuzzFuncs: fuzzFuncMap{ - reflect.TypeOf(&time.Time{}): reflect.ValueOf(fuzzTime), - }, - - fuzzFuncs: fuzzFuncMap{}, - r: rand.New(rand.NewSource(seed)), - nilChance: .2, - minElements: 1, - maxElements: 10, - maxDepth: 100, - } - return f -} - -// NewFromGoFuzz is a helper function that enables using gofuzz (this -// project) with go-fuzz (https://github.com/dvyukov/go-fuzz) for continuous -// fuzzing. Essentially, it enables translating the fuzzing bytes from -// go-fuzz to any Go object using this library. -// -// This implementation promises a constant translation from a given slice of -// bytes to the fuzzed objects. This promise will remain over future -// versions of Go and of this library. -// -// Note: the returned Fuzzer should not be shared between multiple goroutines, -// as its deterministic output will no longer be available. -// -// Example: use go-fuzz to test the function `MyFunc(int)` in the package -// `mypackage`. Add the file: "mypacakge_fuzz.go" with the content: -// -// // +build gofuzz -// package mypacakge -// import fuzz "github.com/google/gofuzz" -// func Fuzz(data []byte) int { -// var i int -// fuzz.NewFromGoFuzz(data).Fuzz(&i) -// MyFunc(i) -// return 0 -// } -func NewFromGoFuzz(data []byte) *Fuzzer { - return New().RandSource(bytesource.New(data)) -} - -// Funcs adds each entry in fuzzFuncs as a custom fuzzing function. -// -// Each entry in fuzzFuncs must be a function taking two parameters. -// The first parameter must be a pointer or map. It is the variable that -// function will fill with random data. The second parameter must be a -// fuzz.Continue, which will provide a source of randomness and a way -// to automatically continue fuzzing smaller pieces of the first parameter. -// -// These functions are called sensibly, e.g., if you wanted custom string -// fuzzing, the function `func(s *string, c fuzz.Continue)` would get -// called and passed the address of strings. Maps and pointers will always -// be made/new'd for you, ignoring the NilChange option. For slices, it -// doesn't make much sense to pre-create them--Fuzzer doesn't know how -// long you want your slice--so take a pointer to a slice, and make it -// yourself. (If you don't want your map/pointer type pre-made, take a -// pointer to it, and make it yourself.) See the examples for a range of -// custom functions. -func (f *Fuzzer) Funcs(fuzzFuncs ...interface{}) *Fuzzer { - for i := range fuzzFuncs { - v := reflect.ValueOf(fuzzFuncs[i]) - if v.Kind() != reflect.Func { - panic("Need only funcs!") - } - t := v.Type() - if t.NumIn() != 2 || t.NumOut() != 0 { - panic("Need 2 in and 0 out params!") - } - argT := t.In(0) - switch argT.Kind() { - case reflect.Ptr, reflect.Map: - default: - panic("fuzzFunc must take pointer or map type") - } - if t.In(1) != reflect.TypeOf(Continue{}) { - panic("fuzzFunc's second parameter must be type fuzz.Continue") - } - f.fuzzFuncs[argT] = v - } - return f -} - -// RandSource causes f to get values from the given source of randomness. -// Use if you want deterministic fuzzing. -func (f *Fuzzer) RandSource(s rand.Source) *Fuzzer { - f.r = rand.New(s) - return f -} - -// NilChance sets the probability of creating a nil pointer, map, or slice to -// 'p'. 'p' should be between 0 (no nils) and 1 (all nils), inclusive. -func (f *Fuzzer) NilChance(p float64) *Fuzzer { - if p < 0 || p > 1 { - panic("p should be between 0 and 1, inclusive.") - } - f.nilChance = p - return f -} - -// NumElements sets the minimum and maximum number of elements that will be -// added to a non-nil map or slice. -func (f *Fuzzer) NumElements(atLeast, atMost int) *Fuzzer { - if atLeast > atMost { - panic("atLeast must be <= atMost") - } - if atLeast < 0 { - panic("atLeast must be >= 0") - } - f.minElements = atLeast - f.maxElements = atMost - return f -} - -func (f *Fuzzer) genElementCount() int { - if f.minElements == f.maxElements { - return f.minElements - } - return f.minElements + f.r.Intn(f.maxElements-f.minElements+1) -} - -func (f *Fuzzer) genShouldFill() bool { - return f.r.Float64() >= f.nilChance -} - -// MaxDepth sets the maximum number of recursive fuzz calls that will be made -// before stopping. This includes struct members, pointers, and map and slice -// elements. -func (f *Fuzzer) MaxDepth(d int) *Fuzzer { - f.maxDepth = d - return f -} - -// Skip fields which match the supplied pattern. Call this multiple times if needed -// This is useful to skip XXX_ fields generated by protobuf -func (f *Fuzzer) SkipFieldsWithPattern(pattern *regexp.Regexp) *Fuzzer { - f.skipFieldPatterns = append(f.skipFieldPatterns, pattern) - return f -} - -// Fuzz recursively fills all of obj's fields with something random. First -// this tries to find a custom fuzz function (see Funcs). If there is no -// custom function this tests whether the object implements fuzz.Interface and, -// if so, calls Fuzz on it to fuzz itself. If that fails, this will see if -// there is a default fuzz function provided by this package. If all of that -// fails, this will generate random values for all primitive fields and then -// recurse for all non-primitives. -// -// This is safe for cyclic or tree-like structs, up to a limit. Use the -// MaxDepth method to adjust how deep you need it to recurse. -// -// obj must be a pointer. Only exported (public) fields can be set (thanks, -// golang :/ ) Intended for tests, so will panic on bad input or unimplemented -// fields. -func (f *Fuzzer) Fuzz(obj interface{}) { - v := reflect.ValueOf(obj) - if v.Kind() != reflect.Ptr { - panic("needed ptr!") - } - v = v.Elem() - f.fuzzWithContext(v, 0) -} - -// FuzzNoCustom is just like Fuzz, except that any custom fuzz function for -// obj's type will not be called and obj will not be tested for fuzz.Interface -// conformance. This applies only to obj and not other instances of obj's -// type. -// Not safe for cyclic or tree-like structs! -// obj must be a pointer. Only exported (public) fields can be set (thanks, golang :/ ) -// Intended for tests, so will panic on bad input or unimplemented fields. -func (f *Fuzzer) FuzzNoCustom(obj interface{}) { - v := reflect.ValueOf(obj) - if v.Kind() != reflect.Ptr { - panic("needed ptr!") - } - v = v.Elem() - f.fuzzWithContext(v, flagNoCustomFuzz) -} - -const ( - // Do not try to find a custom fuzz function. Does not apply recursively. - flagNoCustomFuzz uint64 = 1 << iota -) - -func (f *Fuzzer) fuzzWithContext(v reflect.Value, flags uint64) { - fc := &fuzzerContext{fuzzer: f} - fc.doFuzz(v, flags) -} - -// fuzzerContext carries context about a single fuzzing run, which lets Fuzzer -// be thread-safe. -type fuzzerContext struct { - fuzzer *Fuzzer - curDepth int -} - -func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) { - if fc.curDepth >= fc.fuzzer.maxDepth { - return - } - fc.curDepth++ - defer func() { fc.curDepth-- }() - - if !v.CanSet() { - return - } - - if flags&flagNoCustomFuzz == 0 { - // Check for both pointer and non-pointer custom functions. - if v.CanAddr() && fc.tryCustom(v.Addr()) { - return - } - if fc.tryCustom(v) { - return - } - } - - if fn, ok := fillFuncMap[v.Kind()]; ok { - fn(v, fc.fuzzer.r) - return - } - - switch v.Kind() { - case reflect.Map: - if fc.fuzzer.genShouldFill() { - v.Set(reflect.MakeMap(v.Type())) - n := fc.fuzzer.genElementCount() - for i := 0; i < n; i++ { - key := reflect.New(v.Type().Key()).Elem() - fc.doFuzz(key, 0) - val := reflect.New(v.Type().Elem()).Elem() - fc.doFuzz(val, 0) - v.SetMapIndex(key, val) - } - return - } - v.Set(reflect.Zero(v.Type())) - case reflect.Ptr: - if fc.fuzzer.genShouldFill() { - v.Set(reflect.New(v.Type().Elem())) - fc.doFuzz(v.Elem(), 0) - return - } - v.Set(reflect.Zero(v.Type())) - case reflect.Slice: - if fc.fuzzer.genShouldFill() { - n := fc.fuzzer.genElementCount() - v.Set(reflect.MakeSlice(v.Type(), n, n)) - for i := 0; i < n; i++ { - fc.doFuzz(v.Index(i), 0) - } - return - } - v.Set(reflect.Zero(v.Type())) - case reflect.Array: - if fc.fuzzer.genShouldFill() { - n := v.Len() - for i := 0; i < n; i++ { - fc.doFuzz(v.Index(i), 0) - } - return - } - v.Set(reflect.Zero(v.Type())) - case reflect.Struct: - for i := 0; i < v.NumField(); i++ { - skipField := false - fieldName := v.Type().Field(i).Name - for _, pattern := range fc.fuzzer.skipFieldPatterns { - if pattern.MatchString(fieldName) { - skipField = true - break - } - } - if !skipField { - fc.doFuzz(v.Field(i), 0) - } - } - case reflect.Chan: - fallthrough - case reflect.Func: - fallthrough - case reflect.Interface: - fallthrough - default: - panic(fmt.Sprintf("Can't handle %#v", v.Interface())) - } -} - -// tryCustom searches for custom handlers, and returns true iff it finds a match -// and successfully randomizes v. -func (fc *fuzzerContext) tryCustom(v reflect.Value) bool { - // First: see if we have a fuzz function for it. - doCustom, ok := fc.fuzzer.fuzzFuncs[v.Type()] - if !ok { - // Second: see if it can fuzz itself. - if v.CanInterface() { - intf := v.Interface() - if fuzzable, ok := intf.(Interface); ok { - fuzzable.Fuzz(Continue{fc: fc, Rand: fc.fuzzer.r}) - return true - } - } - // Finally: see if there is a default fuzz function. - doCustom, ok = fc.fuzzer.defaultFuzzFuncs[v.Type()] - if !ok { - return false - } - } - - switch v.Kind() { - case reflect.Ptr: - if v.IsNil() { - if !v.CanSet() { - return false - } - v.Set(reflect.New(v.Type().Elem())) - } - case reflect.Map: - if v.IsNil() { - if !v.CanSet() { - return false - } - v.Set(reflect.MakeMap(v.Type())) - } - default: - return false - } - - doCustom.Call([]reflect.Value{v, reflect.ValueOf(Continue{ - fc: fc, - Rand: fc.fuzzer.r, - })}) - return true -} - -// Interface represents an object that knows how to fuzz itself. Any time we -// find a type that implements this interface we will delegate the act of -// fuzzing itself. -type Interface interface { - Fuzz(c Continue) -} - -// Continue can be passed to custom fuzzing functions to allow them to use -// the correct source of randomness and to continue fuzzing their members. -type Continue struct { - fc *fuzzerContext - - // For convenience, Continue implements rand.Rand via embedding. - // Use this for generating any randomness if you want your fuzzing - // to be repeatable for a given seed. - *rand.Rand -} - -// Fuzz continues fuzzing obj. obj must be a pointer. -func (c Continue) Fuzz(obj interface{}) { - v := reflect.ValueOf(obj) - if v.Kind() != reflect.Ptr { - panic("needed ptr!") - } - v = v.Elem() - c.fc.doFuzz(v, 0) -} - -// FuzzNoCustom continues fuzzing obj, except that any custom fuzz function for -// obj's type will not be called and obj will not be tested for fuzz.Interface -// conformance. This applies only to obj and not other instances of obj's -// type. -func (c Continue) FuzzNoCustom(obj interface{}) { - v := reflect.ValueOf(obj) - if v.Kind() != reflect.Ptr { - panic("needed ptr!") - } - v = v.Elem() - c.fc.doFuzz(v, flagNoCustomFuzz) -} - -// RandString makes a random string up to 20 characters long. The returned string -// may include a variety of (valid) UTF-8 encodings. -func (c Continue) RandString() string { - return randString(c.Rand) -} - -// RandUint64 makes random 64 bit numbers. -// Weirdly, rand doesn't have a function that gives you 64 random bits. -func (c Continue) RandUint64() uint64 { - return randUint64(c.Rand) -} - -// RandBool returns true or false randomly. -func (c Continue) RandBool() bool { - return randBool(c.Rand) -} - -func fuzzInt(v reflect.Value, r *rand.Rand) { - v.SetInt(int64(randUint64(r))) -} - -func fuzzUint(v reflect.Value, r *rand.Rand) { - v.SetUint(randUint64(r)) -} - -func fuzzTime(t *time.Time, c Continue) { - var sec, nsec int64 - // Allow for about 1000 years of random time values, which keeps things - // like JSON parsing reasonably happy. - sec = c.Rand.Int63n(1000 * 365 * 24 * 60 * 60) - c.Fuzz(&nsec) - *t = time.Unix(sec, nsec) -} - -var fillFuncMap = map[reflect.Kind]func(reflect.Value, *rand.Rand){ - reflect.Bool: func(v reflect.Value, r *rand.Rand) { - v.SetBool(randBool(r)) - }, - reflect.Int: fuzzInt, - reflect.Int8: fuzzInt, - reflect.Int16: fuzzInt, - reflect.Int32: fuzzInt, - reflect.Int64: fuzzInt, - reflect.Uint: fuzzUint, - reflect.Uint8: fuzzUint, - reflect.Uint16: fuzzUint, - reflect.Uint32: fuzzUint, - reflect.Uint64: fuzzUint, - reflect.Uintptr: fuzzUint, - reflect.Float32: func(v reflect.Value, r *rand.Rand) { - v.SetFloat(float64(r.Float32())) - }, - reflect.Float64: func(v reflect.Value, r *rand.Rand) { - v.SetFloat(r.Float64()) - }, - reflect.Complex64: func(v reflect.Value, r *rand.Rand) { - v.SetComplex(complex128(complex(r.Float32(), r.Float32()))) - }, - reflect.Complex128: func(v reflect.Value, r *rand.Rand) { - v.SetComplex(complex(r.Float64(), r.Float64())) - }, - reflect.String: func(v reflect.Value, r *rand.Rand) { - v.SetString(randString(r)) - }, - reflect.UnsafePointer: func(v reflect.Value, r *rand.Rand) { - panic("unimplemented") - }, -} - -// randBool returns true or false randomly. -func randBool(r *rand.Rand) bool { - return r.Int31()&(1<<30) == 0 -} - -type int63nPicker interface { - Int63n(int64) int64 -} - -// UnicodeRange describes a sequential range of unicode characters. -// Last must be numerically greater than First. -type UnicodeRange struct { - First, Last rune -} - -// UnicodeRanges describes an arbitrary number of sequential ranges of unicode characters. -// To be useful, each range must have at least one character (First <= Last) and -// there must be at least one range. -type UnicodeRanges []UnicodeRange - -// choose returns a random unicode character from the given range, using the -// given randomness source. -func (ur UnicodeRange) choose(r int63nPicker) rune { - count := int64(ur.Last - ur.First + 1) - return ur.First + rune(r.Int63n(count)) -} - -// CustomStringFuzzFunc constructs a FuzzFunc which produces random strings. -// Each character is selected from the range ur. If there are no characters -// in the range (cr.Last < cr.First), this will panic. -func (ur UnicodeRange) CustomStringFuzzFunc() func(s *string, c Continue) { - ur.check() - return func(s *string, c Continue) { - *s = ur.randString(c.Rand) - } -} - -// check is a function that used to check whether the first of ur(UnicodeRange) -// is greater than the last one. -func (ur UnicodeRange) check() { - if ur.Last < ur.First { - panic("The last encoding must be greater than the first one.") - } -} - -// randString of UnicodeRange makes a random string up to 20 characters long. -// Each character is selected form ur(UnicodeRange). -func (ur UnicodeRange) randString(r *rand.Rand) string { - n := r.Intn(20) - sb := strings.Builder{} - sb.Grow(n) - for i := 0; i < n; i++ { - sb.WriteRune(ur.choose(r)) - } - return sb.String() -} - -// defaultUnicodeRanges sets a default unicode range when user do not set -// CustomStringFuzzFunc() but wants fuzz string. -var defaultUnicodeRanges = UnicodeRanges{ - {' ', '~'}, // ASCII characters - {'\u00a0', '\u02af'}, // Multi-byte encoded characters - {'\u4e00', '\u9fff'}, // Common CJK (even longer encodings) -} - -// CustomStringFuzzFunc constructs a FuzzFunc which produces random strings. -// Each character is selected from one of the ranges of ur(UnicodeRanges). -// Each range has an equal probability of being chosen. If there are no ranges, -// or a selected range has no characters (.Last < .First), this will panic. -// Do not modify any of the ranges in ur after calling this function. -func (ur UnicodeRanges) CustomStringFuzzFunc() func(s *string, c Continue) { - // Check unicode ranges slice is empty. - if len(ur) == 0 { - panic("UnicodeRanges is empty.") - } - // if not empty, each range should be checked. - for i := range ur { - ur[i].check() - } - return func(s *string, c Continue) { - *s = ur.randString(c.Rand) - } -} - -// randString of UnicodeRanges makes a random string up to 20 characters long. -// Each character is selected form one of the ranges of ur(UnicodeRanges), -// and each range has an equal probability of being chosen. -func (ur UnicodeRanges) randString(r *rand.Rand) string { - n := r.Intn(20) - sb := strings.Builder{} - sb.Grow(n) - for i := 0; i < n; i++ { - sb.WriteRune(ur[r.Intn(len(ur))].choose(r)) - } - return sb.String() -} - -// randString makes a random string up to 20 characters long. The returned string -// may include a variety of (valid) UTF-8 encodings. -func randString(r *rand.Rand) string { - return defaultUnicodeRanges.randString(r) -} - -// randUint64 makes random 64 bit numbers. -// Weirdly, rand doesn't have a function that gives you 64 random bits. -func randUint64(r *rand.Rand) uint64 { - return uint64(r.Uint32())<<32 | uint64(r.Uint32()) -} diff --git a/vendor/k8s.io/kube-openapi/pkg/spec3/fuzz.go b/vendor/k8s.io/kube-openapi/pkg/spec3/fuzz.go index 08b6246cebb..25e4fd09ebf 100644 --- a/vendor/k8s.io/kube-openapi/pkg/spec3/fuzz.go +++ b/vendor/k8s.io/kube-openapi/pkg/spec3/fuzz.go @@ -4,7 +4,7 @@ import ( "math/rand" "strings" - fuzz "github.com/google/gofuzz" + "sigs.k8s.io/randfill" "k8s.io/kube-openapi/pkg/validation/spec" ) @@ -25,15 +25,15 @@ func randAlphanumString() string { } var OpenAPIV3FuzzFuncs []interface{} = []interface{}{ - func(s *string, c fuzz.Continue) { + func(s *string, c randfill.Continue) { // All OpenAPI V3 map keys must follow the corresponding // regex. Note that this restricts the range for all other // string values as well. str := randAlphanumString() *s = str }, - func(o *OpenAPI, c fuzz.Continue) { - c.FuzzNoCustom(o) + func(o *OpenAPI, c randfill.Continue) { + c.FillNoCustom(o) o.Version = "3.0.0" for i, val := range o.SecurityRequirement { if val == nil { @@ -48,45 +48,45 @@ var OpenAPIV3FuzzFuncs []interface{} = []interface{}{ } }, - func(r *interface{}, c fuzz.Continue) { + func(r *interface{}, c randfill.Continue) { switch c.Intn(3) { case 0: *r = nil case 1: - n := c.RandString() + "x" + n := c.String(0) + "x" *r = n case 2: n := c.Float64() *r = n } }, - func(v **spec.Info, c fuzz.Continue) { + func(v **spec.Info, c randfill.Continue) { // Info is never nil *v = &spec.Info{} - c.FuzzNoCustom(*v) - (*v).Title = c.RandString() + "x" + c.FillNoCustom(*v) + (*v).Title = c.String(0) + "x" }, - func(v *Paths, c fuzz.Continue) { - c.Fuzz(&v.VendorExtensible) + func(v *Paths, c randfill.Continue) { + c.Fill(&v.VendorExtensible) num := c.Intn(5) if num > 0 { v.Paths = make(map[string]*Path) } for i := 0; i < num; i++ { val := Path{} - c.Fuzz(&val) - v.Paths["/"+c.RandString()] = &val + c.Fill(&val) + v.Paths["/"+c.String(0)] = &val } }, - func(v *SecurityScheme, c fuzz.Continue) { + func(v *SecurityScheme, c randfill.Continue) { if c.Intn(refChance) == 0 { - c.Fuzz(&v.Refable) + c.Fill(&v.Refable) return } switch c.Intn(4) { case 0: v.Type = "apiKey" - v.Name = c.RandString() + "x" + v.Name = c.String(0) + "x" switch c.Intn(3) { case 0: v.In = "query" @@ -101,17 +101,17 @@ var OpenAPIV3FuzzFuncs []interface{} = []interface{}{ v.Type = "oauth2" v.Flows = make(map[string]*OAuthFlow) flow := OAuthFlow{} - flow.AuthorizationUrl = c.RandString() + "x" + flow.AuthorizationUrl = c.String(0) + "x" v.Flows["implicit"] = &flow flow.Scopes = make(map[string]string) flow.Scopes["foo"] = "bar" case 3: v.Type = "openIdConnect" - v.OpenIdConnectUrl = "https://" + c.RandString() + v.OpenIdConnectUrl = "https://" + c.String(0) } v.Scheme = "basic" }, - func(v *spec.Ref, c fuzz.Continue) { + func(v *spec.Ref, c randfill.Continue) { switch c.Intn(7) { case 0: *v = spec.MustCreateRef("#/components/schemas/" + randAlphanumString()) @@ -127,13 +127,13 @@ var OpenAPIV3FuzzFuncs []interface{} = []interface{}{ *v = spec.MustCreateRef("#/components/requestBodies/" + randAlphanumString()) } }, - func(v *Parameter, c fuzz.Continue) { + func(v *Parameter, c randfill.Continue) { if c.Intn(refChance) == 0 { - c.Fuzz(&v.Refable) + c.Fill(&v.Refable) return } - c.Fuzz(&v.ParameterProps) - c.Fuzz(&v.VendorExtensible) + c.Fill(&v.ParameterProps) + c.Fill(&v.VendorExtensible) switch c.Intn(3) { case 0: @@ -145,44 +145,44 @@ var OpenAPIV3FuzzFuncs []interface{} = []interface{}{ v.In = "cookie" } }, - func(v *RequestBody, c fuzz.Continue) { + func(v *RequestBody, c randfill.Continue) { if c.Intn(refChance) == 0 { - c.Fuzz(&v.Refable) + c.Fill(&v.Refable) return } - c.Fuzz(&v.RequestBodyProps) - c.Fuzz(&v.VendorExtensible) + c.Fill(&v.RequestBodyProps) + c.Fill(&v.VendorExtensible) }, - func(v *Header, c fuzz.Continue) { + func(v *Header, c randfill.Continue) { if c.Intn(refChance) == 0 { - c.Fuzz(&v.Refable) + c.Fill(&v.Refable) return } - c.Fuzz(&v.HeaderProps) - c.Fuzz(&v.VendorExtensible) + c.Fill(&v.HeaderProps) + c.Fill(&v.VendorExtensible) }, - func(v *ResponsesProps, c fuzz.Continue) { - c.Fuzz(&v.Default) + func(v *ResponsesProps, c randfill.Continue) { + c.Fill(&v.Default) n := c.Intn(5) for i := 0; i < n; i++ { r2 := Response{} - c.Fuzz(&r2) + c.Fill(&r2) // HTTP Status code in 100-599 Range code := c.Intn(500) + 100 v.StatusCodeResponses = make(map[int]*Response) v.StatusCodeResponses[code] = &r2 } }, - func(v *Response, c fuzz.Continue) { + func(v *Response, c randfill.Continue) { if c.Intn(refChance) == 0 { - c.Fuzz(&v.Refable) + c.Fill(&v.Refable) return } - c.Fuzz(&v.ResponseProps) - c.Fuzz(&v.VendorExtensible) + c.Fill(&v.ResponseProps) + c.Fill(&v.VendorExtensible) }, - func(v *Operation, c fuzz.Continue) { - c.FuzzNoCustom(v) + func(v *Operation, c randfill.Continue) { + c.FillNoCustom(v) // Do not fuzz null values into the array. for i, val := range v.SecurityRequirement { if val == nil { @@ -196,85 +196,85 @@ var OpenAPIV3FuzzFuncs []interface{} = []interface{}{ } } }, - func(v *spec.Extensions, c fuzz.Continue) { + func(v *spec.Extensions, c randfill.Continue) { numChildren := c.Intn(5) for i := 0; i < numChildren; i++ { if *v == nil { *v = spec.Extensions{} } - (*v)["x-"+c.RandString()] = c.RandString() + (*v)["x-"+c.String(0)] = c.String(0) } }, - func(v *spec.ExternalDocumentation, c fuzz.Continue) { - c.Fuzz(&v.Description) + func(v *spec.ExternalDocumentation, c randfill.Continue) { + c.Fill(&v.Description) v.URL = "https://" + randAlphanumString() }, - func(v *spec.SchemaURL, c fuzz.Continue) { + func(v *spec.SchemaURL, c randfill.Continue) { *v = spec.SchemaURL("https://" + randAlphanumString()) }, - func(v *spec.SchemaOrBool, c fuzz.Continue) { + func(v *spec.SchemaOrBool, c randfill.Continue) { *v = spec.SchemaOrBool{} - if c.RandBool() { - v.Allows = c.RandBool() + if c.Bool() { + v.Allows = c.Bool() } else { v.Schema = &spec.Schema{} v.Allows = true - c.Fuzz(&v.Schema) + c.Fill(&v.Schema) } }, - func(v *spec.SchemaOrArray, c fuzz.Continue) { + func(v *spec.SchemaOrArray, c randfill.Continue) { *v = spec.SchemaOrArray{} - if c.RandBool() { + if c.Bool() { schema := spec.Schema{} - c.Fuzz(&schema) + c.Fill(&schema) v.Schema = &schema } else { v.Schemas = []spec.Schema{} numChildren := c.Intn(5) for i := 0; i < numChildren; i++ { schema := spec.Schema{} - c.Fuzz(&schema) + c.Fill(&schema) v.Schemas = append(v.Schemas, schema) } } }, - func(v *spec.SchemaOrStringArray, c fuzz.Continue) { - if c.RandBool() { + func(v *spec.SchemaOrStringArray, c randfill.Continue) { + if c.Bool() { *v = spec.SchemaOrStringArray{} - if c.RandBool() { - c.Fuzz(&v.Property) + if c.Bool() { + c.Fill(&v.Property) } else { - c.Fuzz(&v.Schema) + c.Fill(&v.Schema) } } }, - func(v *spec.Schema, c fuzz.Continue) { + func(v *spec.Schema, c randfill.Continue) { if c.Intn(refChance) == 0 { - c.Fuzz(&v.Ref) + c.Fill(&v.Ref) return } - if c.RandBool() { + if c.Bool() { // file schema - c.Fuzz(&v.Default) - c.Fuzz(&v.Description) - c.Fuzz(&v.Example) - c.Fuzz(&v.ExternalDocs) + c.Fill(&v.Default) + c.Fill(&v.Description) + c.Fill(&v.Example) + c.Fill(&v.ExternalDocs) - c.Fuzz(&v.Format) - c.Fuzz(&v.ReadOnly) - c.Fuzz(&v.Required) - c.Fuzz(&v.Title) + c.Fill(&v.Format) + c.Fill(&v.ReadOnly) + c.Fill(&v.Required) + c.Fill(&v.Title) v.Type = spec.StringOrArray{"file"} } else { // normal schema - c.Fuzz(&v.SchemaProps) - c.Fuzz(&v.SwaggerSchemaProps) - c.Fuzz(&v.VendorExtensible) - c.Fuzz(&v.ExtraProps) + c.Fill(&v.SchemaProps) + c.Fill(&v.SwaggerSchemaProps) + c.Fill(&v.VendorExtensible) + c.Fill(&v.ExtraProps) } }, diff --git a/vendor/modules.txt b/vendor/modules.txt index 19d1779ce61..ed3027f2723 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -303,10 +303,6 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/gofuzz v1.2.0 -## explicit; go 1.12 -github.com/google/gofuzz -github.com/google/gofuzz/bytesource # github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db ## explicit; go 1.22 github.com/google/pprof/profile @@ -1099,7 +1095,7 @@ k8s.io/klog/v2/textlogger ## explicit; go 1.24.0 # k8s.io/kube-controller-manager v0.0.0 => ./staging/src/k8s.io/kube-controller-manager ## explicit; go 1.24.0 -# k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 +# k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 ## explicit; go 1.21 k8s.io/kube-openapi/cmd/openapi-gen k8s.io/kube-openapi/cmd/openapi-gen/args @@ -1265,7 +1261,11 @@ sigs.k8s.io/kustomize/kyaml/yaml/internal/k8sgen/pkg/util/validation/field sigs.k8s.io/kustomize/kyaml/yaml/merge2 sigs.k8s.io/kustomize/kyaml/yaml/schema sigs.k8s.io/kustomize/kyaml/yaml/walk -# sigs.k8s.io/structured-merge-diff/v4 v4.4.2 +# sigs.k8s.io/randfill v1.0.0 +## explicit; go 1.18 +sigs.k8s.io/randfill +sigs.k8s.io/randfill/bytesource +# sigs.k8s.io/structured-merge-diff/v4 v4.6.0 ## explicit; go 1.13 sigs.k8s.io/structured-merge-diff/v4/fieldpath sigs.k8s.io/structured-merge-diff/v4/merge diff --git a/vendor/sigs.k8s.io/randfill/CONTRIBUTING.md b/vendor/sigs.k8s.io/randfill/CONTRIBUTING.md new file mode 100644 index 00000000000..7566c879ce9 --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/CONTRIBUTING.md @@ -0,0 +1,43 @@ +# Contributing Guidelines + +Welcome to Kubernetes. We are excited about the prospect of you joining our [community](https://git.k8s.io/community)! The Kubernetes community abides by the CNCF [code of conduct](code-of-conduct.md). Here is an excerpt: + +_As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities._ + +## Getting Started + +We have full documentation on how to get started contributing here: + + + +- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests +- [Kubernetes Contributor Guide](https://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](https://git.k8s.io/community/contributors/guide#contributing) +- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet) - Common resources for existing developers + +## Mentorship + +- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers! + + + +## Project Management + +The [maintainers](https://github.com/kubernetes-sigs/randfill/blob/main/OWNERS_ALIASES#L12) of this project (and often others who have official positions on the [contributor ladder](https://github.com/kubernetes-sigs/randfill/blob/main/OWNERS_ALIASES)) are responsible for performing project management which oversees development and maintenance of the API, tests, tools, e.t.c. While we try to be generally flexible when it comes to the management of individual pieces (such as Issues or PRs), we have some rules and guidelines which help us plan, coordinate and reduce waste. In this section you'll find some rules/guidelines for contributors related to project management which may extend or go beyond what you would find in the standard [Kubernetes Contributor Guide](https://git.k8s.io/community/contributors/guide). + +### Bumping stale and closed Issues & PRs + +Maintainers are ultimately responsible for triaging new issues and PRs, accepting or declining them, deciding priority and fitting them into milestones intended for future releases. Bots are responsible for marking issues and PRs which stagnate as stale, or closing them if progress does not continue for a long period of time. Due to the nature of this community-driven development effort (we do not have dedicated engineering resources, we rely on the community which is effectively "volunteer time") **not all issues can be accepted, prioritized or completed**. + +You may find times when an issue you're subscribed to and interested in seems to stagnate, or perhaps gets auto-closed. Prior to bumping or directly re-opening issues yourself, we generally ask that you bring these up for discussion on the agenda for one of our community syncs if possible, or bring them up for discussion in Slack or the mailing list as this gives us a better opportunity to discuss the issue and determine viability and logistics. If feasible we **highly recommend being ready to contribute directly** to any stale or unprioritized effort that you want to see move forward, as **the best way to ensure progress is to engage with the community and personally invest time**. + +We (the community) aren't opposed to making exceptions in some cases, but when in doubt please follow the above guidelines before bumping closed or stale issues if you're not ready to personally invest time in them. We are responsible for managing these and without further context or engagement we may set these back to how they were previously organized. diff --git a/vendor/github.com/google/gofuzz/LICENSE b/vendor/sigs.k8s.io/randfill/LICENSE similarity index 99% rename from vendor/github.com/google/gofuzz/LICENSE rename to vendor/sigs.k8s.io/randfill/LICENSE index d6456956733..9dd29274c3d 100644 --- a/vendor/github.com/google/gofuzz/LICENSE +++ b/vendor/sigs.k8s.io/randfill/LICENSE @@ -1,4 +1,3 @@ - Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -179,7 +178,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" + boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -187,7 +186,8 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2014 The gofuzz Authors + Copyright 2025 The Kubernetes Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/sigs.k8s.io/randfill/NOTICE b/vendor/sigs.k8s.io/randfill/NOTICE new file mode 100644 index 00000000000..6984e71f654 --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/NOTICE @@ -0,0 +1,24 @@ +When donating the randfill project to the CNCF, we could not reach all the +gofuzz contributors to sign the CNCF CLA. As such, according to the CNCF rules +to donate a repository, we must add a NOTICE referencing section 7 of the CLA +with a list of developers who could not be reached. + +`7. Should You wish to submit work that is not Your original creation, You may +submit it to the Foundation separately from any Contribution, identifying the +complete details of its source and of any license or other restriction +(including, but not limited to, related patents, trademarks, and license +agreements) of which you are personally aware, and conspicuously marking the +work as "Submitted on behalf of a third-party: [named here]".` + +Submitted on behalf of a third-party: @dnephin (Daniel Nephin) +Submitted on behalf of a third-party: @AlekSi (Alexey Palazhchenko) +Submitted on behalf of a third-party: @bbigras (Bruno Bigras) +Submitted on behalf of a third-party: @samirkut (Samir) +Submitted on behalf of a third-party: @posener (Eyal Posener) +Submitted on behalf of a third-party: @Ashikpaul (Ashik Paul) +Submitted on behalf of a third-party: @kwongtailau (Kwongtai) +Submitted on behalf of a third-party: @ericcornelissen (Eric Cornelissen) +Submitted on behalf of a third-party: @eclipseo (Robert-AndrĂ© Mauchin) +Submitted on behalf of a third-party: @yanzhoupan (Andrew Pan) +Submitted on behalf of a third-party: @STRRL (Zhiqiang ZHOU) +Submitted on behalf of a third-party: @disconnect3d (Disconnect3d) diff --git a/vendor/sigs.k8s.io/randfill/OWNERS b/vendor/sigs.k8s.io/randfill/OWNERS new file mode 100644 index 00000000000..59f6a50f6b6 --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/OWNERS @@ -0,0 +1,8 @@ +# See the OWNERS docs at https://go.k8s.io/owners +# See the OWNERS_ALIASES file at https://github.com/kubernetes-sigs/randfill/blob/main/OWNERS_ALIASES for a list of members for each alias. + +approvers: + - sig-testing-leads + - thockin + +reviewers: [] diff --git a/vendor/sigs.k8s.io/randfill/OWNERS_ALIASES b/vendor/sigs.k8s.io/randfill/OWNERS_ALIASES new file mode 100644 index 00000000000..927f1209b1d --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/OWNERS_ALIASES @@ -0,0 +1,14 @@ +# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md +# This file should be kept in sync with k/org. + +aliases: + # Reference: https://github.com/kubernetes/org/blob/main/OWNERS_ALIASES + sig-testing-leads: + - BenTheElder + - alvaroaleman + - aojea + - cjwagner + - jbpratt + - michelle192837 + - pohly + - xmcqueen diff --git a/vendor/github.com/google/gofuzz/README.md b/vendor/sigs.k8s.io/randfill/README.md similarity index 53% rename from vendor/github.com/google/gofuzz/README.md rename to vendor/sigs.k8s.io/randfill/README.md index b503aae7d71..d892fc9f5d5 100644 --- a/vendor/github.com/google/gofuzz/README.md +++ b/vendor/sigs.k8s.io/randfill/README.md @@ -1,39 +1,46 @@ -gofuzz +randfill ====== -gofuzz is a library for populating go objects with random values. +randfill is a library for populating go objects with random values. -[![GoDoc](https://godoc.org/github.com/google/gofuzz?status.svg)](https://godoc.org/github.com/google/gofuzz) -[![Travis](https://travis-ci.org/google/gofuzz.svg?branch=master)](https://travis-ci.org/google/gofuzz) +This is a fork of github.com/google/gofuzz, which was archived. + +NOTE: This repo is supported only for use within Kubernetes. It is not our +intention to support general use. That said, if it works for you, that's +great! If you have a problem, please feel free to file an issue, but be aware +that it may not be a priority for us to fix it unless it is affecting +Kubernetes. PRs are welcome, within reason. + +[![GoDoc](https://godoc.org/sigs.k8s.io/randfill?status.svg)](https://godoc.org/sigs.k8s.io/randfill) This is useful for testing: * Do your project's objects really serialize/unserialize correctly in all cases? * Is there an incorrectly formatted object that will cause your project to panic? -Import with ```import "github.com/google/gofuzz"``` +Import with ```import "sigs.k8s.io/randfill"``` You can use it on single variables: ```go -f := fuzz.New() +f := randfill.New() var myInt int -f.Fuzz(&myInt) // myInt gets a random value. +f.Fill(&myInt) // myInt gets a random value. ``` You can use it on maps: ```go -f := fuzz.New().NilChance(0).NumElements(1, 1) +f := randfill.New().NilChance(0).NumElements(1, 1) var myMap map[ComplexKeyType]string -f.Fuzz(&myMap) // myMap will have exactly one element. +f.Fill(&myMap) // myMap will have exactly one element. ``` Customize the chance of getting a nil pointer: ```go -f := fuzz.New().NilChance(.5) +f := randfill.New().NilChance(.5) var fancyStruct struct { A, B, C, D *string } -f.Fuzz(&fancyStruct) // About half the pointers should be set. +f.Fill(&fancyStruct) // About half the pointers should be set. ``` You can even customize the randomization completely if needed: @@ -49,25 +56,27 @@ type MyInfo struct { BInfo *string } -f := fuzz.New().NilChance(0).Funcs( - func(e *MyInfo, c fuzz.Continue) { +f := randfill.New().NilChance(0).Funcs( + func(e *MyInfo, c randfill.Continue) { switch c.Intn(2) { case 0: e.Type = A - c.Fuzz(&e.AInfo) + c.Fill(&e.AInfo) case 1: e.Type = B - c.Fuzz(&e.BInfo) + c.Fill(&e.BInfo) } }, ) var myObject MyInfo -f.Fuzz(&myObject) // Type will correspond to whether A or B info is set. +f.Fill(&myObject) // Type will correspond to whether A or B info is set. ``` See more examples in ```example_test.go```. +## dvyukov/go-fuzz integration + You can use this library for easier [go-fuzz](https://github.com/dvyukov/go-fuzz)ing. go-fuzz provides the user a byte-slice, which should be converted to different inputs for the tested function. This library can help convert the byte slice. Consider for @@ -76,11 +85,11 @@ example a fuzz test for a the function `mypackage.MyFunc` that takes an int argu // +build gofuzz package mypackage -import fuzz "github.com/google/gofuzz" +import "sigs.k8s.io/randfill" func Fuzz(data []byte) int { var i int - fuzz.NewFromGoFuzz(data).Fuzz(&i) + randfill.NewFromGoFuzz(data).Fill(&i) MyFunc(i) return 0 } diff --git a/vendor/sigs.k8s.io/randfill/SECURITY_CONTACTS b/vendor/sigs.k8s.io/randfill/SECURITY_CONTACTS new file mode 100644 index 00000000000..91d78533783 --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/SECURITY_CONTACTS @@ -0,0 +1,16 @@ +# Defined below are the security contacts for this repo. +# +# They are the contact point for the Product Security Committee to reach out +# to for triaging and handling of incoming issues. +# +# The below names agree to abide by the +# [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy) +# and will be removed and replaced if they violate that agreement. +# +# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE +# INSTRUCTIONS AT https://kubernetes.io/security/ + +thockin +BenTheElder +aojea +pohly diff --git a/vendor/github.com/google/gofuzz/bytesource/bytesource.go b/vendor/sigs.k8s.io/randfill/bytesource/bytesource.go similarity index 100% rename from vendor/github.com/google/gofuzz/bytesource/bytesource.go rename to vendor/sigs.k8s.io/randfill/bytesource/bytesource.go diff --git a/vendor/sigs.k8s.io/randfill/code-of-conduct.md b/vendor/sigs.k8s.io/randfill/code-of-conduct.md new file mode 100644 index 00000000000..0d15c00cf32 --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/code-of-conduct.md @@ -0,0 +1,3 @@ +# Kubernetes Community Code of Conduct + +Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) diff --git a/vendor/sigs.k8s.io/randfill/randfill.go b/vendor/sigs.k8s.io/randfill/randfill.go new file mode 100644 index 00000000000..b7348248440 --- /dev/null +++ b/vendor/sigs.k8s.io/randfill/randfill.go @@ -0,0 +1,682 @@ +/* +Copyright 2014 Google Inc. All rights reserved. +Copyright 2014 The gofuzz Authors. +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package randfill is a library for populating go objects with random values. +package randfill + +import ( + "fmt" + "math/rand" + "reflect" + "regexp" + "sync" + "time" + "unsafe" + + "strings" + + "sigs.k8s.io/randfill/bytesource" +) + +// funcMap is a map from a type to a function that randfills that type. The +// function is a reflect.Value because the type being filled is different for +// each func. +type funcMap map[reflect.Type]reflect.Value + +// Filler knows how to fill any object with random fields. +type Filler struct { + customFuncs funcMap + defaultFuncs funcMap + r *rand.Rand + nilChance float64 + minElements int + maxElements int + maxDepth int + allowUnexportedFields bool + skipFieldPatterns []*regexp.Regexp + + lock sync.Mutex +} + +// New returns a new Filler. Customize your Filler further by calling Funcs, +// RandSource, NilChance, or NumElements in any order. +func New() *Filler { + return NewWithSeed(time.Now().UnixNano()) +} + +func NewWithSeed(seed int64) *Filler { + f := &Filler{ + defaultFuncs: funcMap{ + reflect.TypeOf(&time.Time{}): reflect.ValueOf(randfillTime), + }, + + customFuncs: funcMap{}, + r: rand.New(rand.NewSource(seed)), + nilChance: .2, + minElements: 1, + maxElements: 10, + maxDepth: 100, + allowUnexportedFields: false, + } + return f +} + +// NewFromGoFuzz is a helper function that enables using randfill (this +// project) with go-fuzz (https://github.com/dvyukov/go-fuzz) for continuous +// fuzzing. Essentially, it enables translating the fuzzing bytes from +// go-fuzz to any Go object using this library. +// +// This implementation promises a constant translation from a given slice of +// bytes to the fuzzed objects. This promise will remain over future +// versions of Go and of this library. +// +// Note: the returned Filler should not be shared between multiple goroutines, +// as its deterministic output will no longer be available. +// +// Example: use go-fuzz to test the function `MyFunc(int)` in the package +// `mypackage`. Add the file: "mypackage_fuzz.go" with the content: +// +// // +build gofuzz +// package mypackage +// import "sigs.k8s.io/randfill" +// +// func Fuzz(data []byte) int { +// var i int +// randfill.NewFromGoFuzz(data).Fill(&i) +// MyFunc(i) +// return 0 +// } +func NewFromGoFuzz(data []byte) *Filler { + return New().RandSource(bytesource.New(data)) +} + +// Funcs registers custom fill functions for this Filler. +// +// Each entry in customFuncs must be a function taking two parameters. +// The first parameter must be a pointer or map. It is the variable that +// function will fill with random data. The second parameter must be a +// randfill.Continue, which will provide a source of randomness and a way +// to automatically continue filling smaller pieces of the first parameter. +// +// These functions are called sensibly, e.g., if you wanted custom string +// filling, the function `func(s *string, c randfill.Continue)` would get +// called and passed the address of strings. Maps and pointers will always +// be made/new'd for you, ignoring the NilChance option. For slices, it +// doesn't make much sense to pre-create them--Filler doesn't know how +// long you want your slice--so take a pointer to a slice, and make it +// yourself. (If you don't want your map/pointer type pre-made, take a +// pointer to it, and make it yourself.) See the examples for a range of +// custom functions. +// +// If a function is already registered for a type, and a new function is +// provided, the previous function will be replaced with the new one. +func (f *Filler) Funcs(customFuncs ...interface{}) *Filler { + for i := range customFuncs { + v := reflect.ValueOf(customFuncs[i]) + if v.Kind() != reflect.Func { + panic("Filler.Funcs: all arguments must be functions") + } + t := v.Type() + if t.NumIn() != 2 || t.NumOut() != 0 { + panic("Filler.Funcs: all customFuncs must have 2 arguments and 0 returns") + } + argT := t.In(0) + switch argT.Kind() { + case reflect.Ptr, reflect.Map: + default: + panic("Filler.Funcs: customFuncs' first argument must be a pointer or map type") + } + if t.In(1) != reflect.TypeOf(Continue{}) { + panic("Filler.Funcs: customFuncs' second argument must be a randfill.Continue") + } + f.customFuncs[argT] = v + } + return f +} + +// RandSource causes this Filler to get values from the given source of +// randomness. Use this if you want deterministic filling. +func (f *Filler) RandSource(s rand.Source) *Filler { + f.r = rand.New(s) + return f +} + +// NilChance sets the probability of creating a nil pointer, map, or slice to +// 'p'. 'p' should be between 0 (no nils) and 1 (all nils), inclusive. +func (f *Filler) NilChance(p float64) *Filler { + if p < 0 || p > 1 { + panic("Filler.NilChance: p must be between 0 and 1, inclusive") + } + f.nilChance = p + return f +} + +// NumElements sets the minimum and maximum number of elements that will be +// added to a non-nil map or slice. +func (f *Filler) NumElements(min, max int) *Filler { + if min < 0 { + panic("Filler.NumElements: min must be >= 0") + } + if min > max { + panic("Filler.NumElements: min must be <= max") + } + f.minElements = min + f.maxElements = max + return f +} + +func (f *Filler) genElementCount() int { + if f.minElements == f.maxElements { + return f.minElements + } + return f.minElements + f.r.Intn(f.maxElements-f.minElements+1) +} + +func (f *Filler) genShouldFill() bool { + return f.r.Float64() >= f.nilChance +} + +// MaxDepth sets the maximum number of recursive fill calls that will be made +// before stopping. This includes struct members, pointers, and map and slice +// elements. +func (f *Filler) MaxDepth(d int) *Filler { + f.maxDepth = d + return f +} + +// AllowUnexportedFields defines whether to fill unexported fields. +func (f *Filler) AllowUnexportedFields(flag bool) *Filler { + f.allowUnexportedFields = flag + return f +} + +// SkipFieldsWithPattern tells this Filler to skip any field whose name matches +// the supplied pattern. Call this multiple times if needed. This is useful to +// skip XXX_ fields generated by protobuf. +func (f *Filler) SkipFieldsWithPattern(pattern *regexp.Regexp) *Filler { + f.skipFieldPatterns = append(f.skipFieldPatterns, pattern) + return f +} + +// SimpleSelfFiller represents an object that knows how to randfill itself. +// +// Unlike NativeSelfFiller, this interface does not cause the type in question +// to depend on the randfill package. This is most useful for simple types. For +// more complex types, consider using NativeSelfFiller. +type SimpleSelfFiller interface { + // RandFill fills the current object with random data. + RandFill(r *rand.Rand) +} + +// NativeSelfFiller represents an object that knows how to randfill itself. +// +// Unlike SimpleSelfFiller, this interface allows for recursive filling of +// child objects with the same rules as the parent Filler. +type NativeSelfFiller interface { + // RandFill fills the current object with random data. + RandFill(c Continue) +} + +// Fill recursively fills all of obj's fields with something random. First +// this tries to find a custom fill function (see Funcs). If there is no +// custom function, this tests whether the object implements SimpleSelfFiller +// or NativeSelfFiller and if so, calls RandFill on it to fill itself. If that +// fails, this will see if there is a default fill function provided by this +// package. If all of that fails, this will generate random values for all +// primitive fields and then recurse for all non-primitives. +// +// This is safe for cyclic or tree-like structs, up to a limit. Use the +// MaxDepth method to adjust how deep you need it to recurse. +// +// obj must be a pointer. Exported (public) fields can always be set, and if +// the AllowUnexportedFields() modifier was called it can try to set unexported +// (private) fields, too. +// +// This is intended for tests, so will panic on bad input or unimplemented +// types. This method takes a lock for the whole Filler, so it is not +// reentrant. See Continue. +func (f *Filler) Fill(obj interface{}) { + f.lock.Lock() + defer f.lock.Unlock() + + v := reflect.ValueOf(obj) + if v.Kind() != reflect.Ptr { + panic("Filler.Fill: obj must be a pointer") + } + v = v.Elem() + f.fillWithContext(v, 0) +} + +// FillNoCustom is just like Fill, except that any custom fill function for +// obj's type will not be called and obj will not be tested for +// SimpleSelfFiller or NativeSelfFiller. This applies only to obj and not other +// instances of obj's type or to obj's child fields. +// +// obj must be a pointer. Exported (public) fields can always be set, and if +// the AllowUnexportedFields() modifier was called it can try to set unexported +// (private) fields, too. +// +// This is intended for tests, so will panic on bad input or unimplemented +// types. This method takes a lock for the whole Filler, so it is not +// reentrant. See Continue. +func (f *Filler) FillNoCustom(obj interface{}) { + f.lock.Lock() + defer f.lock.Unlock() + + v := reflect.ValueOf(obj) + if v.Kind() != reflect.Ptr { + panic("Filler.FillNoCustom: obj must be a pointer") + } + v = v.Elem() + f.fillWithContext(v, flagNoCustomFill) +} + +const ( + // Do not try to find a custom fill function. Does not apply recursively. + flagNoCustomFill uint64 = 1 << iota +) + +func (f *Filler) fillWithContext(v reflect.Value, flags uint64) { + fc := &fillerContext{filler: f} + fc.doFill(v, flags) +} + +// fillerContext carries context about a single filling run, which lets Filler +// be thread-safe. +type fillerContext struct { + filler *Filler + curDepth int +} + +func (fc *fillerContext) doFill(v reflect.Value, flags uint64) { + if fc.curDepth >= fc.filler.maxDepth { + return + } + fc.curDepth++ + defer func() { fc.curDepth-- }() + + if !v.CanSet() { + if !fc.filler.allowUnexportedFields || !v.CanAddr() { + return + } + v = reflect.NewAt(v.Type(), unsafe.Pointer(v.UnsafeAddr())).Elem() + } + + if flags&flagNoCustomFill == 0 { + // Check for both pointer and non-pointer custom functions. + if v.CanAddr() && fc.tryCustom(v.Addr()) { + return + } + if fc.tryCustom(v) { + return + } + } + + if fn, ok := fillFuncMap[v.Kind()]; ok { + fn(v, fc.filler.r) + return + } + + switch v.Kind() { + case reflect.Map: + if fc.filler.genShouldFill() { + v.Set(reflect.MakeMap(v.Type())) + n := fc.filler.genElementCount() + for i := 0; i < n; i++ { + key := reflect.New(v.Type().Key()).Elem() + fc.doFill(key, 0) + val := reflect.New(v.Type().Elem()).Elem() + fc.doFill(val, 0) + v.SetMapIndex(key, val) + } + return + } + v.Set(reflect.Zero(v.Type())) + case reflect.Ptr: + if fc.filler.genShouldFill() { + v.Set(reflect.New(v.Type().Elem())) + fc.doFill(v.Elem(), 0) + return + } + v.Set(reflect.Zero(v.Type())) + case reflect.Slice: + if fc.filler.genShouldFill() { + n := fc.filler.genElementCount() + v.Set(reflect.MakeSlice(v.Type(), n, n)) + for i := 0; i < n; i++ { + fc.doFill(v.Index(i), 0) + } + return + } + v.Set(reflect.Zero(v.Type())) + case reflect.Array: + if fc.filler.genShouldFill() { + n := v.Len() + for i := 0; i < n; i++ { + fc.doFill(v.Index(i), 0) + } + return + } + v.Set(reflect.Zero(v.Type())) + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + skipField := false + fieldName := v.Type().Field(i).Name + for _, pattern := range fc.filler.skipFieldPatterns { + if pattern.MatchString(fieldName) { + skipField = true + break + } + } + if !skipField { + fc.doFill(v.Field(i), 0) + } + } + case reflect.Chan: + fallthrough + case reflect.Func: + fallthrough + case reflect.Interface: + fallthrough + default: + panic(fmt.Sprintf("can't fill type %v, kind %v", v.Type(), v.Kind())) + } +} + +// tryCustom searches for custom handlers, and returns true iff it finds a match +// and successfully randomizes v. +func (fc *fillerContext) tryCustom(v reflect.Value) bool { + // First: see if we have a fill function for it. + doCustom, ok := fc.filler.customFuncs[v.Type()] + if !ok { + // Second: see if it can fill itself. + if v.CanInterface() { + intf := v.Interface() + if fillable, ok := intf.(SimpleSelfFiller); ok { + fillable.RandFill(fc.filler.r) + return true + } + if fillable, ok := intf.(NativeSelfFiller); ok { + fillable.RandFill(Continue{fc: fc, Rand: fc.filler.r}) + return true + } + } + // Finally: see if there is a default fill function. + doCustom, ok = fc.filler.defaultFuncs[v.Type()] + if !ok { + return false + } + } + + switch v.Kind() { + case reflect.Ptr: + if v.IsNil() { + if !v.CanSet() { + return false + } + v.Set(reflect.New(v.Type().Elem())) + } + case reflect.Map: + if v.IsNil() { + if !v.CanSet() { + return false + } + v.Set(reflect.MakeMap(v.Type())) + } + default: + return false + } + + doCustom.Call([]reflect.Value{ + v, + reflect.ValueOf(Continue{ + fc: fc, + Rand: fc.filler.r, + }), + }) + return true +} + +// Continue can be passed to custom fill functions to allow them to use +// the correct source of randomness and to continue filling their members. +type Continue struct { + fc *fillerContext + + // For convenience, Continue implements rand.Rand via embedding. + // Use this for generating any randomness if you want your filling + // to be repeatable for a given seed. + *rand.Rand +} + +// Fill continues filling obj. obj must be a pointer or a reflect.Value of a +// pointer. See Filler.Fill. +func (c Continue) Fill(obj interface{}) { + v, ok := obj.(reflect.Value) + if !ok { + v = reflect.ValueOf(obj) + } + if v.Kind() != reflect.Ptr { + panic("Continue.Fill: obj must be a pointer") + } + v = v.Elem() + c.fc.doFill(v, 0) +} + +// FillNoCustom continues filling obj, except that any custom fill function for +// obj's type will not be called and obj will not be tested for +// SimpleSelfFiller or NativeSelfFiller. See Filler.FillNoCustom. +func (c Continue) FillNoCustom(obj interface{}) { + v, ok := obj.(reflect.Value) + if !ok { + v = reflect.ValueOf(obj) + } + if v.Kind() != reflect.Ptr { + panic("Continue.FillNoCustom: obj must be a pointer") + } + v = v.Elem() + c.fc.doFill(v, flagNoCustomFill) +} + +const defaultStringMaxLen = 20 + +// String makes a random string up to n characters long. If n is 0, the default +// size range is [0-20). The returned string may include a variety of (valid) +// UTF-8 encodings. +func (c Continue) String(n int) string { + return randString(c.Rand, n) +} + +// Uint64 makes random 64 bit numbers. +// Weirdly, rand doesn't have a function that gives you 64 random bits. +func (c Continue) Uint64() uint64 { + return randUint64(c.Rand) +} + +// Bool returns true or false randomly. +func (c Continue) Bool() bool { + return randBool(c.Rand) +} + +func fillInt(v reflect.Value, r *rand.Rand) { + v.SetInt(int64(randUint64(r))) +} + +func fillUint(v reflect.Value, r *rand.Rand) { + v.SetUint(randUint64(r)) +} + +func randfillTime(t *time.Time, c Continue) { + var sec, nsec int64 + // Allow for about 1000 years of random time values, which keeps things + // like JSON parsing reasonably happy. + sec = c.Rand.Int63n(1000 * 365 * 24 * 60 * 60) + // Nanosecond values greater than 1Bn are technically allowed but result in + // time.Time values with invalid timezone offsets. + nsec = c.Rand.Int63n(999999999) + *t = time.Unix(sec, nsec) +} + +var fillFuncMap = map[reflect.Kind]func(reflect.Value, *rand.Rand){ + reflect.Bool: func(v reflect.Value, r *rand.Rand) { + v.SetBool(randBool(r)) + }, + reflect.Int: fillInt, + reflect.Int8: fillInt, + reflect.Int16: fillInt, + reflect.Int32: fillInt, + reflect.Int64: fillInt, + reflect.Uint: fillUint, + reflect.Uint8: fillUint, + reflect.Uint16: fillUint, + reflect.Uint32: fillUint, + reflect.Uint64: fillUint, + reflect.Uintptr: fillUint, + reflect.Float32: func(v reflect.Value, r *rand.Rand) { + v.SetFloat(float64(r.Float32())) + }, + reflect.Float64: func(v reflect.Value, r *rand.Rand) { + v.SetFloat(r.Float64()) + }, + reflect.Complex64: func(v reflect.Value, r *rand.Rand) { + v.SetComplex(complex128(complex(r.Float32(), r.Float32()))) + }, + reflect.Complex128: func(v reflect.Value, r *rand.Rand) { + v.SetComplex(complex(r.Float64(), r.Float64())) + }, + reflect.String: func(v reflect.Value, r *rand.Rand) { + v.SetString(randString(r, 0)) + }, + reflect.UnsafePointer: func(v reflect.Value, r *rand.Rand) { + panic("filling of UnsafePointers is not implemented") + }, +} + +// randBool returns true or false randomly. +func randBool(r *rand.Rand) bool { + return r.Int31()&(1<<30) == 0 +} + +type int63nPicker interface { + Int63n(int64) int64 +} + +// UnicodeRange describes a sequential range of unicode characters. +// Last must be numerically greater than First. +type UnicodeRange struct { + First, Last rune +} + +// UnicodeRanges describes an arbitrary number of sequential ranges of unicode characters. +// To be useful, each range must have at least one character (First <= Last) and +// there must be at least one range. +type UnicodeRanges []UnicodeRange + +// choose returns a random unicode character from the given range, using the +// given randomness source. +func (ur UnicodeRange) choose(r int63nPicker) rune { + count := int64(ur.Last - ur.First + 1) + return ur.First + rune(r.Int63n(count)) +} + +// CustomStringFillFunc constructs a FillFunc which produces random strings. +// Each character is selected from the range ur. If there are no characters +// in the range (cr.Last < cr.First), this will panic. +func (ur UnicodeRange) CustomStringFillFunc(n int) func(s *string, c Continue) { + ur.check() + return func(s *string, c Continue) { + *s = ur.randString(c.Rand, n) + } +} + +// check is a function that used to check whether the first of ur(UnicodeRange) +// is greater than the last one. +func (ur UnicodeRange) check() { + if ur.Last < ur.First { + panic("UnicodeRange.check: the last encoding must be greater than the first") + } +} + +// randString of UnicodeRange makes a random string up to 20 characters long. +// Each character is selected form ur(UnicodeRange). +func (ur UnicodeRange) randString(r *rand.Rand, max int) string { + if max == 0 { + max = defaultStringMaxLen + } + n := r.Intn(max) + sb := strings.Builder{} + sb.Grow(n) + for i := 0; i < n; i++ { + sb.WriteRune(ur.choose(r)) + } + return sb.String() +} + +// defaultUnicodeRanges sets a default unicode range when users do not set +// CustomStringFillFunc() but want to fill strings. +var defaultUnicodeRanges = UnicodeRanges{ + {' ', '~'}, // ASCII characters + {'\u00a0', '\u02af'}, // Multi-byte encoded characters + {'\u4e00', '\u9fff'}, // Common CJK (even longer encodings) +} + +// CustomStringFillFunc constructs a FillFunc which produces random strings. +// Each character is selected from one of the ranges of ur(UnicodeRanges). +// Each range has an equal probability of being chosen. If there are no ranges, +// or a selected range has no characters (.Last < .First), this will panic. +// Do not modify any of the ranges in ur after calling this function. +func (ur UnicodeRanges) CustomStringFillFunc(n int) func(s *string, c Continue) { + // Check unicode ranges slice is empty. + if len(ur) == 0 { + panic("UnicodeRanges is empty") + } + // if not empty, each range should be checked. + for i := range ur { + ur[i].check() + } + return func(s *string, c Continue) { + *s = ur.randString(c.Rand, n) + } +} + +// randString of UnicodeRanges makes a random string up to 20 characters long. +// Each character is selected form one of the ranges of ur(UnicodeRanges), +// and each range has an equal probability of being chosen. +func (ur UnicodeRanges) randString(r *rand.Rand, max int) string { + if max == 0 { + max = defaultStringMaxLen + } + n := r.Intn(max) + sb := strings.Builder{} + sb.Grow(n) + for i := 0; i < n; i++ { + sb.WriteRune(ur[r.Intn(len(ur))].choose(r)) + } + return sb.String() +} + +// randString makes a random string up to 20 characters long. The returned string +// may include a variety of (valid) UTF-8 encodings. +func randString(r *rand.Rand, max int) string { + return defaultUnicodeRanges.randString(r, max) +} + +// randUint64 makes random 64 bit numbers. +// Weirdly, rand doesn't have a function that gives you 64 random bits. +func randUint64(r *rand.Rand) uint64 { + return uint64(r.Uint32())<<32 | uint64(r.Uint32()) +} diff --git a/vendor/sigs.k8s.io/structured-merge-diff/v4/merge/update.go b/vendor/sigs.k8s.io/structured-merge-diff/v4/merge/update.go index 34ab2d6fb4f..455818ff858 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/v4/merge/update.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/v4/merge/update.go @@ -33,6 +33,9 @@ type UpdaterBuilder struct { Converter Converter IgnoreFilter map[fieldpath.APIVersion]fieldpath.Filter + // IgnoredFields provides a set of fields to ignore for each + IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set + // Stop comparing the new object with old object after applying. // This was initially used to avoid spurious etcd update, but // since that's vastly inefficient, we've come-up with a better @@ -46,6 +49,7 @@ func (u *UpdaterBuilder) BuildUpdater() *Updater { return &Updater{ Converter: u.Converter, IgnoreFilter: u.IgnoreFilter, + IgnoredFields: u.IgnoredFields, returnInputOnNoop: u.ReturnInputOnNoop, } } @@ -56,6 +60,9 @@ type Updater struct { // Deprecated: This will eventually become private. Converter Converter + // Deprecated: This will eventually become private. + IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set + // Deprecated: This will eventually become private. IgnoreFilter map[fieldpath.APIVersion]fieldpath.Filter @@ -70,8 +77,19 @@ func (s *Updater) update(oldObject, newObject *typed.TypedValue, version fieldpa return nil, nil, fmt.Errorf("failed to compare objects: %v", err) } - versions := map[fieldpath.APIVersion]*typed.Comparison{ - version: compare.FilterFields(s.IgnoreFilter[version]), + var versions map[fieldpath.APIVersion]*typed.Comparison + + if s.IgnoredFields != nil && s.IgnoreFilter != nil { + return nil, nil, fmt.Errorf("IgnoreFilter and IgnoreFilter may not both be set") + } + if s.IgnoredFields != nil { + versions = map[fieldpath.APIVersion]*typed.Comparison{ + version: compare.ExcludeFields(s.IgnoredFields[version]), + } + } else { + versions = map[fieldpath.APIVersion]*typed.Comparison{ + version: compare.FilterFields(s.IgnoreFilter[version]), + } } for manager, managerSet := range managers { @@ -101,7 +119,12 @@ func (s *Updater) update(oldObject, newObject *typed.TypedValue, version fieldpa if err != nil { return nil, nil, fmt.Errorf("failed to compare objects: %v", err) } - versions[managerSet.APIVersion()] = compare.FilterFields(s.IgnoreFilter[managerSet.APIVersion()]) + + if s.IgnoredFields != nil { + versions[managerSet.APIVersion()] = compare.ExcludeFields(s.IgnoredFields[managerSet.APIVersion()]) + } else { + versions[managerSet.APIVersion()] = compare.FilterFields(s.IgnoreFilter[managerSet.APIVersion()]) + } } conflictSet := managerSet.Set().Intersection(compare.Modified.Union(compare.Added)) @@ -154,7 +177,16 @@ func (s *Updater) Update(liveObject, newObject *typed.TypedValue, version fieldp managers[manager] = fieldpath.NewVersionedSet(fieldpath.NewSet(), version, false) } set := managers[manager].Set().Difference(compare.Removed).Union(compare.Modified).Union(compare.Added) - ignoreFilter := s.IgnoreFilter[version] + + if s.IgnoredFields != nil && s.IgnoreFilter != nil { + return nil, nil, fmt.Errorf("IgnoreFilter and IgnoreFilter may not both be set") + } + var ignoreFilter fieldpath.Filter + if s.IgnoredFields != nil { + ignoreFilter = fieldpath.NewExcludeSetFilter(s.IgnoredFields[version]) + } else { + ignoreFilter = s.IgnoreFilter[version] + } if ignoreFilter != nil { set = ignoreFilter.Filter(set) } @@ -189,7 +221,15 @@ func (s *Updater) Apply(liveObject, configObject *typed.TypedValue, version fiel return nil, fieldpath.ManagedFields{}, fmt.Errorf("failed to get field set: %v", err) } - ignoreFilter := s.IgnoreFilter[version] + if s.IgnoredFields != nil && s.IgnoreFilter != nil { + return nil, nil, fmt.Errorf("IgnoreFilter and IgnoreFilter may not both be set") + } + var ignoreFilter fieldpath.Filter + if s.IgnoredFields != nil { + ignoreFilter = fieldpath.NewExcludeSetFilter(s.IgnoredFields[version]) + } else { + ignoreFilter = s.IgnoreFilter[version] + } if ignoreFilter != nil { set = ignoreFilter.Filter(set) } diff --git a/vendor/sigs.k8s.io/structured-merge-diff/v4/typed/typed.go b/vendor/sigs.k8s.io/structured-merge-diff/v4/typed/typed.go index 9be90282806..7edaa6d4892 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/v4/typed/typed.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/v4/typed/typed.go @@ -32,6 +32,21 @@ const ( AllowDuplicates ValidationOptions = iota ) +// extractItemsOptions is the options available when extracting items. +type extractItemsOptions struct { + appendKeyFields bool +} + +type ExtractItemsOption func(*extractItemsOptions) + +// WithAppendKeyFields configures ExtractItems to include key fields. +// It is exported for use in configuring ExtractItems. +func WithAppendKeyFields() ExtractItemsOption { + return func(opts *extractItemsOptions) { + opts.appendKeyFields = true + } +} + // AsTyped accepts a value and a type and returns a TypedValue. 'v' must have // type 'typeName' in the schema. An error is returned if the v doesn't conform // to the schema. @@ -187,7 +202,37 @@ func (tv TypedValue) RemoveItems(items *fieldpath.Set) *TypedValue { } // ExtractItems returns a value with only the provided list or map items extracted from the value. -func (tv TypedValue) ExtractItems(items *fieldpath.Set) *TypedValue { +func (tv TypedValue) ExtractItems(items *fieldpath.Set, opts ...ExtractItemsOption) *TypedValue { + options := &extractItemsOptions{} + for _, opt := range opts { + opt(options) + } + if options.appendKeyFields { + tvPathSet, err := tv.ToFieldSet() + if err == nil { + keyFieldPathSet := fieldpath.NewSet() + items.Iterate(func(path fieldpath.Path) { + if !tvPathSet.Has(path) { + return + } + for i, pe := range path { + if pe.Key == nil { + continue + } + for _, keyField := range *pe.Key { + keyName := keyField.Name + // Create a new slice with the same elements as path[:i+1], but set its capacity to len(path[:i+1]). + // This ensures that appending to keyFieldPath creates a new underlying array, avoiding accidental + // modification of the original slice (path). + keyFieldPath := append(path[:i+1:i+1], fieldpath.PathElement{FieldName: &keyName}) + keyFieldPathSet.Insert(keyFieldPath) + } + } + }) + items = items.Union(keyFieldPathSet) + } + } + tv.value = removeItemsWithSchema(tv.value, items, tv.schema, tv.typeRef, true) return &tv } diff --git a/vendor/sigs.k8s.io/structured-merge-diff/v4/value/scalar.go b/vendor/sigs.k8s.io/structured-merge-diff/v4/value/scalar.go index c78a4c18d12..5824219e513 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/v4/value/scalar.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/v4/value/scalar.go @@ -43,7 +43,7 @@ func IntCompare(lhs, rhs int64) int { func BoolCompare(lhs, rhs bool) int { if lhs == rhs { return 0 - } else if lhs == false { + } else if !lhs { return -1 } return 1