MCPcopy
hub / github.com/istio/istio / FuzzNewBootstrapServer

Function FuzzNewBootstrapServer

tests/fuzz/bootstrap_fuzzer.go:28–82  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

26)
27
28func FuzzNewBootstrapServer(data []byte) int {
29 f := fuzz.NewConsumer(data)
30
31 // Create mesh config file
32 meshConfigFile, err := createRandomConfigFile(f)
33 if err != nil {
34 return 0
35 }
36 defer os.Remove(meshConfigFile)
37 _, err = os.Stat(meshConfigFile)
38 if err != nil {
39 return 0
40 }
41 // Validate mesh config file
42 meshConfigYaml, err := mesh.ReadMeshConfigData(meshConfigFile)
43 if err != nil {
44 return 0
45 }
46 _, err = mesh.ApplyMeshConfigDefaults(meshConfigYaml)
47 if err != nil {
48 return 0
49 }
50
51 // Create kube config file
52 kubeConfigFile, err := createRandomConfigFile(f)
53 if err != nil {
54 return 0
55 }
56 defer os.Remove(kubeConfigFile)
57
58 args := &bootstrap.PilotArgs{}
59 err = f.GenerateStruct(args)
60 if err != nil {
61 return 0
62 }
63
64 args.MeshConfigFile = meshConfigFile
65 args.RegistryOptions.KubeConfig = kubeConfigFile
66 args.ShutdownDuration = 1 * time.Millisecond
67
68 stop := make(chan struct{})
69 s, err := bootstrap.NewServer(args)
70 if err != nil {
71 return 0
72 }
73 err = s.Start(stop)
74 if err != nil {
75 return 0
76 }
77 defer func() {
78 close(stop)
79 s.WaitUntilCompletion()
80 }()
81 return 1
82}

Callers

nothing calls this directly

Calls 8

StartMethod · 0.95
WaitUntilCompletionMethod · 0.95
ReadMeshConfigDataFunction · 0.92
ApplyMeshConfigDefaultsFunction · 0.92
NewServerFunction · 0.92
createRandomConfigFileFunction · 0.85
StatMethod · 0.80
RemoveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…