commit | 43f748f91a6a08f4005836db2330155d4349d6d4 | [log] [tgz] |
---|---|---|
author | Vitaly Buka <vitalybuka@chromium.org> | Thu Jan 05 20:59:32 2017 -0800 |
committer | Vitaly Buka <vitalybuka@google.com> | Wed Jan 11 18:39:21 2017 +0000 |
tree | 3e2936d9aab55f16f8f7cad5c3eb52a497cf0ad0 | |
parent | c2f0c697a0d74c1a3ed91382383f58138431852a [diff] |
Simplify proto comparison in test. Change-Id: Ia8d559f375be5bdf7cdb0d979140b9fdbd513c85 Reviewed-on: https://team-review.git.corp.google.com/58370 Reviewed-by: Mike Aizatsky <aizatsky@google.com>
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, 200); }
See also the ProtobufMutatorMessagesTest.UsageExample
test from protobuf_mutator_test.cc.
TODO