Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restructure example and tweak readme (fixes issue #3; fixes issue #4) #5

Merged
merged 1 commit into from Aug 2, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

restructure example and tweak readme (fixes issue #3; fixes isssue #4)

  • Loading branch information
kjk committed Aug 2, 2019
commit 9b2a80dbada7e469e53782745d443fb095d315fb
@@ -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,27 +138,33 @@ 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
./fuzzit create job --type $1 --branch $TRAVIS_BRANCH --revision $TRAVIS_COMMIT $TARGET_ID ./fuzzer
```

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_\<Os\>_\<Arch\>
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.
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.