From 4039583ccd9260aa58759bfa2a0883f684601428 Mon Sep 17 00:00:00 2001 From: Ashley Svetlik Date: Thu, 13 Jun 2019 11:11:47 -0500 Subject: [PATCH] Added fuzzing code and readme.md to explain --- roaring/README.md | 30 ++++++++++++++++++++++++++++++ roaring/fuzzer.go | 12 ++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 roaring/README.md create mode 100644 roaring/fuzzer.go diff --git a/roaring/README.md b/roaring/README.md new file mode 100644 index 000000000..3599a6813 --- /dev/null +++ b/roaring/README.md @@ -0,0 +1,30 @@ +# The Fuzzer + +For complete documentation on go-fuzz, please see: https://github.com/dvyukov/go-fuzz + +The fuzzer in relation to the roaring package checks the `Bitmap.UnmarshalBinary` function found in `roaring.go`. In order to use the fuzzer, you can follow these steps: + +`cd $GOPATH/src/github.com/pilosa/pilosa/roaring` + +`go-fuzz-build ./` + +You must now make the workdir/corpus directory. This is achieved by: + +`mkdir workdir/corpus` + +The fuzzer needs some input to start the fuzzing with. Copy some sample fragments into the workdir/corpus folder. Once you have copied your sample inputs, you are ready to run the fuzzer: + +`go-fuzz` + +## Understanding the Fuzzer Output + +The fuzzer will output something similar to the follwoing: + +`2015/04/25 12:39:53 workers: 8, corpus: 124 (12s ago), crashers: 37, restarts: 1/15, execs: 35342 (2941/sec), cover: 403, uptime: 12s` + +The most important part of the output is the `crashers` and `cover`. The crashers records how many combinations were discovered that fail and the cover tells you how much code is being accessed. +For a complete explanation of the output, please see: https://github.com/dvyukov/go-fuzz. + +The fuzzer will document the crashers in a folder labeled "crashers." It will record the fragment and the error that was produced in two separate files within this folder. This is the final product. + +Happy Fuzzing! diff --git a/roaring/fuzzer.go b/roaring/fuzzer.go new file mode 100644 index 000000000..9d31326a6 --- /dev/null +++ b/roaring/fuzzer.go @@ -0,0 +1,12 @@ +// +build gofuzz + +package roaring + +func FuzzBitmapUnmarshalBinary(data []byte) int { + b := NewBitmap() + err := b.UnmarshalBinary(data) + if err != nil { + return 0 + } + return 1 +}