From 9b2a80dbada7e469e53782745d443fb095d315fb Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Fri, 2 Aug 2019 08:45:19 -0700 Subject: [PATCH] restructure example and tweak readme (fixes issue #3; fixes isssue #4) --- README.md | 24 ++++++++++++------- ci/fuzzit.sh | 6 ++++- .../parse_complex.go => parse_complex.go | 0 ...e_complex_fuzz.go => parse_complex_fuzz.go | 0 ...e_complex_test.go => parse_complex_test.go | 0 5 files changed, 20 insertions(+), 10 deletions(-) rename pkg/parser/parse_complex.go => parse_complex.go (100%) rename pkg/parser/parse_complex_fuzz.go => parse_complex_fuzz.go (100%) rename pkg/parser/parse_complex_test.go => parse_complex_test.go (100%) diff --git a/README.md b/README.md index cc770cd..6336ad3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This is an example of how to integrate your [go-fuzz](https://github.com/dvyukov This example will show the following steps: * [Building and running locally a simple go-fuzz target](#building-go-fuzz-target) -* [Integrate the go-fuzz target with Fuzzit via Travis-CI](#integrating-with-fuzzit) +* [Integrate the go-fuzz target with Fuzzit via Travis-CI](#integrating-with-fuzzit-from-ci) Result: * Fuzzit will run the fuzz targets continuously on daily basis with the latest release. @@ -82,7 +82,7 @@ go get github.com/fuzzitdev/example-go ```bash cd /go/src/github.com/fuzzitdev/example-go -go-fuzz-build -libfuzzer -o fuzzer.a ./... +go-fuzz-build -libfuzzer -o fuzzer.a . clang-9 -fsanitize=fuzzer fuzzer.a -o fuzzer ``` @@ -138,17 +138,20 @@ artifact_prefix='./'; Test unit written to ./crash-df779ced6b712c5fca247e465de2d Base64: RlVaWkk= ``` +## Integrating with Fuzzit from CI -## Integrating with Fuzzit - -The integration with fuzzit is easy and consists of adding a travis stage, downloading the fuzzit cli, -authenticating and uploading the fuzzer to fuzzit. +The best way to integrate with Fuzzit is by adding a stage in your Contintous Build system +(like Travis CI or Circle CI). In that stage: +* build a fuzz target +* download `fuzzit` cli +* authenticate with `fuzzit auth` +* create a fuzzing job by uploading fuzz target here is the relevant snippet from the [./ci/fuzzit.sh](https://github.com/fuzzitdev/example-go/blob/master/ci/fuzzit.sh) which is being run by [.travis.yml](https://github.com/fuzzitdev/example-go/blob/master/.travis.yml) ```bash -wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v1.2.7/fuzzit_Linux_x86_64 +wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.0.0/fuzzit_Linux_x86_64 chmod a+x fuzzit ./fuzzit auth ${FUZZIT_API_KEY} export TARGET_ID=2n6hO2dQzylLxX5GGhRG @@ -156,9 +159,12 @@ export TARGET_ID=2n6hO2dQzylLxX5GGhRG ``` NOTE: In production it is advised to download a pinned version of the [CLI](https://github.com/fuzzitdev/fuzzit) -like in the example. In development you can use latest with the following link: -https://github.com/fuzzitdev/fuzzit/releases/latest/download/fuzzit_\_\ +like in the example. In development you can use latest version: +https://github.com/fuzzitdev/fuzzit/releases/latest/download/fuzzit_${OS}_${ARCH}. +Valid values for `${OS}` are: `Linux`, `Darwin`, `Windows`. +Valid values for `${ARCH}` are: `x86_64` and `i386`. +The steps are: * Authenticate with the API key (you should keep this secret) you can find in the fuzzit settings dashboard. * Upload the fuzzer via create job command and create the fuzzing job. In This example we use two type of jobs: * Fuzzing job which is run on every push to master which continuous the previous job just with the new release. diff --git a/ci/fuzzit.sh b/ci/fuzzit.sh index c62875e..ad69207 100755 --- a/ci/fuzzit.sh +++ b/ci/fuzzit.sh @@ -1,5 +1,9 @@ set -xe +## go-fuzz doesn't support modules for now, so ensure we do everything +## in the old style GOPATH way +export GO111MODULE="off" + if [ -z ${1+x} ]; then echo "must call with job type as first argument e.g. 'fuzzing' or 'sanity'" echo "see https://github.com/fuzzitdev/example-go/blob/master/.travis.yml" @@ -11,7 +15,7 @@ go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz- ## build and send to fuzzit go build ./... -go-fuzz-build -libfuzzer -o fuzzer.a ./... +go-fuzz-build -libfuzzer -o fuzzer.a . clang -fsanitize=fuzzer fuzzer.a -o fuzzer wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.0.0/fuzzit_Linux_x86_64 diff --git a/pkg/parser/parse_complex.go b/parse_complex.go similarity index 100% rename from pkg/parser/parse_complex.go rename to parse_complex.go diff --git a/pkg/parser/parse_complex_fuzz.go b/parse_complex_fuzz.go similarity index 100% rename from pkg/parser/parse_complex_fuzz.go rename to parse_complex_fuzz.go diff --git a/pkg/parser/parse_complex_test.go b/parse_complex_test.go similarity index 100% rename from pkg/parser/parse_complex_test.go rename to parse_complex_test.go