fuzzer

package
v1.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
	return []interface{}{
		func(np *networking.NetworkPolicyPeer, c fuzz.Continue) {
			c.FuzzNoCustom(np)

			if np.IPBlock != nil {
				np.IPBlock = &networking.IPBlock{
					CIDR:   "192.168.1.0/24",
					Except: []string{"192.168.1.1/24", "192.168.1.2/24"},
				}
			}
		},
		func(np *networking.NetworkPolicy, c fuzz.Continue) {
			c.FuzzNoCustom(np)

			if len(np.Spec.PolicyTypes) == 0 {
				np.Spec.PolicyTypes = []networking.PolicyType{networking.PolicyTypeIngress}
			}
		},
		func(path *networking.HTTPIngressPath, c fuzz.Continue) {
			c.FuzzNoCustom(path)
			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)

			if c.RandBool() {
				p.Name = ""
				if p.Number == 0 {
					p.Number = 1
				}
			} else {
				p.Number = 0
				if p.Name == "" {
					p.Name = "portname"
				}
			}
		},
		func(p *networking.IngressClass, c fuzz.Continue) {
			c.FuzzNoCustom(p)

			if p.Spec.Parameters == nil || p.Spec.Parameters.Scope == nil {
				p.Spec.Parameters = &networking.IngressClassParametersReference{
					Scope: utilpointer.String(networking.IngressClassParametersReferenceScopeCluster),
				}
			}
		},
		func(obj *networking.IPAddress, c fuzz.Continue) {
			c.FuzzNoCustom(obj)

			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)
			boolean := []bool{false, true}

			is6 := boolean[c.Rand.Intn(2)]
			primary := generateRandomCIDR(is6, c)
			obj.Spec.CIDRs = []string{primary}

			if boolean[c.Rand.Intn(2)] {
				obj.Spec.CIDRs = append(obj.Spec.CIDRs, generateRandomCIDR(!is6, c))
			}
		},
	}
}

Funcs returns the fuzzer functions for the networking api group.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL