-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
As the official fuzzer implementation provided by golang, the native fuzzer should be well suited for various usage scenarios. However, currently native fuzzers only support general mutation algorithms for built-in types. Therefore, in many cases, the native fuzzer cannot efficiently generate test inputs. For example, when testing a DSL parser, the mutator will generate a large amount of output that cannot pass the syntax or semantic check. A possible solution is to provide support for custom mutators, so that users can implement custom mutators for various fuzz targets and reuse other parts of the native fuzzer.
I tried on the existing code and designed the following interface:
type CustomMutator interface {
Marshal() ([]byte, error)
Unmarshal([]byte) error
Mutate() error
}
The object that implements the above interface can be passed as an argument to the testing.F.Fuzz method, and it will call the Mutate method to use the custom mutation algorithm. The Marshal and Unmarshal methods ensure that it can be imported/exported to a corpus file.
I think supporting custom mutator will bring the following benefits:
- the usage scenarios of native fuzzer are expanded
- it is more convenient for the community to test and optimize mutation algorithms
- the interface of custom mutator is very similar to the struct mutation interface mentioned in the draft proposal, so implementing a custom mutator may be a way to support struct mutation
In addition, custom mutator will also bring some side effects, such as the custom mutator code will be instrumented, which may affect performance and the accuracy of coverage statistics.
/cc @jayconrod
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status