commit | 20e7b06bb0e561b7a7637331599f291b978327ec | [log] [tgz] |
---|---|---|
author | Kostya Serebryany <konstantin.s.serebryany@gmail.com> | Thu Dec 15 11:45:50 2016 -0800 |
committer | Kostya Serebryany <konstantin.s.serebryany@gmail.com> | Thu Dec 15 11:45:50 2016 -0800 |
tree | 2c8c39776775315d84595bc0a26c3e70a93a52d8 | |
parent | 2d4a8d8ea76e1f5038a1a01b255daafc7ec65123 [diff] |
docs
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