commit | ba12972cb72d3e0bf5fea8d963a25f64e0d3ac0c | [log] [tgz] |
---|---|---|
author | Vitaly Buka <[email protected]> | Thu Dec 15 01:29:15 2016 |
committer | Vitaly Buka <[email protected]> | Fri Dec 16 22:17:58 2016 |
tree | 99b3def8bda0eb7711bb90860accc73bc90f9ced | |
parent | 482c172dcf83d91c8dea56af631b9bf30384f00d [diff] |
Hide keep_initialized argument and keep messages always initialized Change-Id: I504bff28dc346f3ed55a3302f9604bdff125f629 Reviewed-on: https://team-review.git.corp.google.com/57397 Reviewed-by: Vitaly Buka <[email protected]>
libprotobuf-mutator is a library to randomly mutate protobuffers.
It could be used together with guided fuzzing engines, such as libFuzzer.
Install prerequisites:
sudo apt-get update sudo apt-get install binutils cmake ninja-build
Compile and test everything:
mkdir build cd build cmake ../cmake/ -GNinja -DCMAKE_BUILD_TYPE=Debug ninja check
To use libprotobuf-mutator simply include protobuf_mutator.h and protobuf_mutator.cc into your build files.
The ProtobufMutator
class implements mutations of the protobuf tree structure and mutations of individual fields. The field mutation logic is very basic -- for better results you should override the ProtobufMutator::Mutate*
methods with more sophisticated logic, e.g. using libFuzzer's mutators.
To apply one mutation to a protobuf object do the following:
class MyProtobufMutator : public ProtobufMutator { public: MyProtobufMutator(uint32_t seed) : ProtobufMutator(seed) {} // Optionally redefine the Mutate* methods to perform more sophisticated mutations. } void Mutate(MyMessage* message) { MyProtobufMutator mutator(my_random_seed); mutator.Mutate(message, 100, 200); }
See also the ProtobufMutatorMessagesTest.UsageExample
test from protobuf_mutator_test.cc.
TODO