...

Source file src/github.com/linkerd/linkerd2/pkg/profiles/profiles_fuzzer.go

Documentation: github.com/linkerd/linkerd2/pkg/profiles

     1  package profiles
     2  
     3  import (
     4  	"os"
     5  
     6  	fuzz "github.com/AdaLogics/go-fuzz-headers"
     7  )
     8  
     9  // FuzzProfilesValidate fuzzes the ProfilesValidate function.
    10  func FuzzProfilesValidate(data []byte) int {
    11  	_ = Validate(data)
    12  	return 1
    13  }
    14  
    15  // FuzzRenderProto fuzzes the RenderProto function.
    16  func FuzzRenderProto(data []byte) int {
    17  	f := fuzz.NewConsumer(data)
    18  	protodata, err := f.GetBytes()
    19  	if err != nil {
    20  		return 0
    21  	}
    22  	namespace, err := f.GetString()
    23  	if err != nil {
    24  		return 0
    25  	}
    26  	name, err := f.GetString()
    27  	if err != nil {
    28  		return 0
    29  	}
    30  	clusterDomain, err := f.GetString()
    31  	if err != nil {
    32  		return 0
    33  	}
    34  	protofile, err := os.Create("protofile")
    35  	if err != nil {
    36  		return 0
    37  	}
    38  	defer protofile.Close()
    39  	defer os.Remove(protofile.Name())
    40  
    41  	_, err = protofile.Write(protodata)
    42  	if err != nil {
    43  		return 0
    44  	}
    45  	_, err = RenderProto(protofile.Name(), namespace, name, clusterDomain)
    46  	if err != nil {
    47  		return 0
    48  	}
    49  	return 1
    50  }
    51  

View as plain text