Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Commit 0035dc4

Browse files
author
Yevgeny Pats
committed
Merge branch 'master' of github.com:fuzzitdev/example-go
2 parents 006c142 + ab41121 commit 0035dc4

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This is an example of how to integrate your [go-fuzz](https://github.com/dvyukov
88

99
This example will show the following steps:
1010
* [Building and running locally a simple go-fuzz target](#building-go-fuzz-target)
11-
* [Integrate the go-fuzz target with Fuzzit via Travis-CI](#integrating-with-fuzzit)
11+
* [Integrate the go-fuzz target with Fuzzit via Travis-CI](#integrating-with-fuzzit-from-ci)
1212

1313
Result:
1414
* Fuzzit will run the fuzz targets continuously on daily basis with the latest release.
@@ -82,14 +82,14 @@ go get github.com/fuzzitdev/example-go
8282

8383
```bash
8484
cd /go/src/github.com/fuzzitdev/example-go
85-
go-fuzz-build -libfuzzer ./...
86-
clang-9 -fsanitize=fuzzer parser-fuzz.a -o parser-fuzz.libfuzzer
85+
go-fuzz-build -libfuzzer -o fuzzer.a .
86+
clang-9 -fsanitize=fuzzer fuzzer.a -o fuzzer
8787
```
8888

8989
### Running the fuzzer
9090

9191
```bash
92-
./parser-fuzz.libfuzzer
92+
./fuzzer
9393
```
9494

9595
Will print the following output and stacktrace:
@@ -138,27 +138,33 @@ artifact_prefix='./'; Test unit written to ./crash-df779ced6b712c5fca247e465de2d
138138
Base64: RlVaWkk=
139139
```
140140

141+
## Integrating with Fuzzit from CI
141142

142-
## Integrating with Fuzzit
143-
144-
The integration with fuzzit is easy and consists of adding a travis stage, downloading the fuzzit cli,
145-
authenticating and uploading the fuzzer to fuzzit.
143+
The best way to integrate with Fuzzit is by adding a stage in your Contintous Build system
144+
(like Travis CI or Circle CI). In that stage:
145+
* build a fuzz target
146+
* download `fuzzit` cli
147+
* authenticate with `fuzzit auth`
148+
* create a fuzzing job by uploading fuzz target
146149

147150
here is the relevant snippet from the [./ci/fuzzit.sh](https://github.com/fuzzitdev/example-go/blob/master/ci/fuzzit.sh)
148151
which is being run by [.travis.yml](https://github.com/fuzzitdev/example-go/blob/master/.travis.yml)
149152

150153
```bash
151-
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v1.2.7/fuzzit_Linux_x86_64
154+
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.0.0/fuzzit_Linux_x86_64
152155
chmod a+x fuzzit
153156
./fuzzit auth ${FUZZIT_API_KEY}
154157
export TARGET_ID=2n6hO2dQzylLxX5GGhRG
155158
./fuzzit create job --type $1 --branch $TRAVIS_BRANCH --revision $TRAVIS_COMMIT $TARGET_ID ./fuzzer
156159
```
157160

158161
NOTE: In production it is advised to download a pinned version of the [CLI](https://github.com/fuzzitdev/fuzzit)
159-
like in the example. In development you can use latest with the following link:
160-
https://github.com/fuzzitdev/fuzzit/releases/latest/download/fuzzit_\<Os\>_\<Arch\>
162+
like in the example. In development you can use latest version:
163+
https://github.com/fuzzitdev/fuzzit/releases/latest/download/fuzzit_${OS}_${ARCH}.
164+
Valid values for `${OS}` are: `Linux`, `Darwin`, `Windows`.
165+
Valid values for `${ARCH}` are: `x86_64` and `i386`.
161166

167+
The steps are:
162168
* Authenticate with the API key (you should keep this secret) you can find in the fuzzit settings dashboard.
163169
* Upload the fuzzer via create job command and create the fuzzing job. In This example we use two type of jobs:
164170
* Fuzzing job which is run on every push to master which continuous the previous job just with the new release.

ci/fuzzit.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
set -xe
22

3+
## go-fuzz doesn't support modules for now, so ensure we do everything
4+
## in the old style GOPATH way
5+
export GO111MODULE="off"
6+
7+
if [ -z ${1+x} ]; then
8+
echo "must call with job type as first argument e.g. 'fuzzing' or 'sanity'"
9+
echo "see https://github.com/fuzzitdev/example-go/blob/master/.travis.yml"
10+
exit 1
11+
fi
12+
313
## Install go-fuzz
414
go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
515

616
## build fuzzer
717
go build ./...
8-
go-fuzz-build -libfuzzer -o fuzzer.a ./...
18+
go-fuzz-build -libfuzzer -o fuzzer.a .
919
clang -fsanitize=fuzzer fuzzer.a -o fuzzer
1020

1121
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.1/fuzzit_Linux_x86_64

0 commit comments

Comments
 (0)