mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Merge pull request #2004 from asvetlik/master
Added fuzzing code and readme.md to explain the fuzzer
This commit is contained in:
commit
7aa2211a6d
2 changed files with 60 additions and 0 deletions
34
roaring/README.md
Normal file
34
roaring/README.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# 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 Pilosa fragments into the workdir/corpus folder. For example:
|
||||
|
||||
`cp ~/.pilosa/my-index/my-field/views/standard/fragments/0 workdir/corpus`
|
||||
|
||||
Once you have copied your sample inputs, you are ready to run the fuzzer:
|
||||
|
||||
`go-fuzz -bin=roaring-fuzz.zip -workdir=workdir -func=FuzzBitmapUnmarshalBinary`
|
||||
|
||||
## 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!
|
||||
26
roaring/fuzzer.go
Normal file
26
roaring/fuzzer.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2017 Pilosa Corp.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build gofuzz
|
||||
|
||||
package roaring
|
||||
|
||||
func FuzzBitmapUnmarshalBinary(data []byte) int {
|
||||
b := NewBitmap()
|
||||
err := b.UnmarshalBinary(data)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue