vendor: github.com/google/gofuzz v1.1.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
		| @@ -62,7 +62,7 @@ github.com/cilium/ebpf                              60c3aa43f488292fe2ee50fb8b83 | |||||||
| github.com/davecgh/go-spew                          8991bc29aa16c548c550c7ff78260e27b9ab7c73 # v1.1.1 | github.com/davecgh/go-spew                          8991bc29aa16c548c550c7ff78260e27b9ab7c73 # v1.1.1 | ||||||
| github.com/docker/spdystream                        449fdfce4d962303d702fec724ef0ad181c92528 | github.com/docker/spdystream                        449fdfce4d962303d702fec724ef0ad181c92528 | ||||||
| github.com/emicklei/go-restful                      b993709ae1a4f6dd19cfa475232614441b11c9d5 # v2.9.5 | github.com/emicklei/go-restful                      b993709ae1a4f6dd19cfa475232614441b11c9d5 # v2.9.5 | ||||||
| github.com/google/gofuzz                            f140a6486e521aad38f5917de355cbf147cc0496 # v1.0.0 | github.com/google/gofuzz                            db92cf7ae75e4a7a28abc005addab2b394362888 # v1.1.0 | ||||||
| github.com/json-iterator/go                         03217c3e97663914aec3faafde50d081f197a0a2 # v1.1.8 | github.com/json-iterator/go                         03217c3e97663914aec3faafde50d081f197a0a2 # v1.1.8 | ||||||
| github.com/modern-go/concurrent                     bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 | github.com/modern-go/concurrent                     bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 | ||||||
| github.com/modern-go/reflect2                       4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 | github.com/modern-go/reflect2                       4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								vendor/github.com/google/gofuzz/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/google/gofuzz/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ gofuzz | |||||||
|  |  | ||||||
| gofuzz is a library for populating go objects with random values. | gofuzz is a library for populating go objects with random values. | ||||||
|  |  | ||||||
| [](https://godoc.org/github.com/google/gofuzz) | [](https://godoc.org/github.com/google/gofuzz) | ||||||
| [](https://travis-ci.org/google/gofuzz) | [](https://travis-ci.org/google/gofuzz) | ||||||
|  |  | ||||||
| This is useful for testing: | This is useful for testing: | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								vendor/github.com/google/gofuzz/fuzz.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/google/gofuzz/fuzz.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,6 +20,7 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"math/rand" | 	"math/rand" | ||||||
| 	"reflect" | 	"reflect" | ||||||
|  | 	"regexp" | ||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -35,6 +36,7 @@ type Fuzzer struct { | |||||||
| 	minElements       int | 	minElements       int | ||||||
| 	maxElements       int | 	maxElements       int | ||||||
| 	maxDepth          int | 	maxDepth          int | ||||||
|  | 	skipFieldPatterns []*regexp.Regexp | ||||||
| } | } | ||||||
|  |  | ||||||
| // New returns a new Fuzzer. Customize your Fuzzer further by calling Funcs, | // New returns a new Fuzzer. Customize your Fuzzer further by calling Funcs, | ||||||
| @@ -150,6 +152,13 @@ func (f *Fuzzer) MaxDepth(d int) *Fuzzer { | |||||||
| 	return f | 	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 | // 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 | // 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, | // custom function this tests whether the object implements fuzz.Interface and, | ||||||
| @@ -274,8 +283,18 @@ func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) { | |||||||
| 		v.Set(reflect.Zero(v.Type())) | 		v.Set(reflect.Zero(v.Type())) | ||||||
| 	case reflect.Struct: | 	case reflect.Struct: | ||||||
| 		for i := 0; i < v.NumField(); i++ { | 		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) | 				fc.doFuzz(v.Field(i), 0) | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
| 	case reflect.Chan: | 	case reflect.Chan: | ||||||
| 		fallthrough | 		fallthrough | ||||||
| 	case reflect.Func: | 	case reflect.Func: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sebastiaan van Stijn
					Sebastiaan van Stijn