-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add fuzzit support * Do local regression fuzz testing
- Loading branch information
1 parent
d4833f6
commit 1241ed7
Showing
7 changed files
with
160 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,57 @@ | ||
language: go | ||
|
||
# Docker is required for fuzzit regression tests | ||
services: | ||
- docker | ||
|
||
dist: bionic | ||
|
||
os: | ||
- linux | ||
- osx | ||
go: | ||
- tip | ||
- 1.12 | ||
- 1.12.x | ||
- 1.11.x | ||
- 1.10.x | ||
- 1.9.x | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
matrix: | ||
allow_failures: | ||
- tip | ||
fast_finish: true | ||
|
||
env: | ||
global: | ||
secure: "v/F0oI9zE9mcpEp4AVdHzSSHbe5ZFtH6B0i/BiUXKdQRQ10+JMPDOFRJQti7yxjMwltyd/QSFmR50Fl108sQYpo4xdlEXMHp2Y6OAN6crrp6PuHbLYgDWu3df/cH7/BqDyIq1uX8KZEeQssnygYN8hN4tpJCUg+NIb40Lm57Zsodt8DVjjyDWQQFDL7soNyAwGwQIqEyJsn+NUieXWEB1Qnt0xUtPIReuLlrwXR8wC1nLEjG9yz4ftDHHQdhVbO2b+xGWyaJ7QB5ixztaQP8Jnny6kSW9j6zEhJVuzdZ6d3xz23ibCbzSXBHdIUEI9u6ifQj8BYXr8fFS0FB3++IxgAYSs3ybZ+qEwuAxSBBm6YNW+3FrfDknVwTQscjKqnXPisjUqaRC9b31hke0tXzBq1488hE+wxMXeDM4LwWT5IMEO2gz0WGQXxmdVit72DIjCZxJkf1TvZZ0YH7Y//6wJTYYP9xulsy4gqu8CuFdWiF3fiGc3p5DTIS75nJ/Yy76Sa1pRPASKCujfLxtHE6Mt0XKvSolIXklYIzBkjN6vn80N6JIrqtqlimBGPW/Ec6+dwbmRe2AcOKRl4y7pZsGYhJhqdue1mucUYO/e2QeBZJGkqqG+zF5AW0v8x29BHvMwViAonc8o9eelkJ8khYzc/Qeq05pZnR/N/Pqfc+68k=" | ||
|
||
before_install: | ||
- go get -t -v ./... | ||
# - go get -v golang.org/x/tools/cmd/goimports | ||
|
||
script: | ||
# TODO(@kirilldanshin) | ||
# - test -z "$(goimports -d $(find . -type f -name '*.go' -not -path "./vendor/*"))" | ||
# build test for supported platforms | ||
- GOOS=linux go build | ||
- GOOS=darwin go build | ||
- GOOS=freebsd go build | ||
- GOOS=windows go build | ||
- GOARCH=386 go build | ||
|
||
# run tests on a standard platform | ||
- go test -v ./... | ||
|
||
# run tests with the race detector as well | ||
- go test -race -v ./... | ||
jobs: | ||
include: | ||
- stage: test | ||
script: | ||
# TODO(@kirilldanshin) | ||
# - test -z "$(goimports -d $(find . -type f -name '*.go' -not -path "./vendor/*"))" | ||
# build test for supported platforms | ||
- GOOS=linux go build | ||
- GOOS=darwin go build | ||
- GOOS=freebsd go build | ||
- GOOS=windows go build | ||
- GOARCH=386 go build | ||
|
||
# run tests on a standard platform | ||
- go test -v ./... | ||
|
||
# run tests with the race detector as well | ||
- go test -race -v ./... | ||
- stage: fuzzit.dev | ||
os: | ||
- linux | ||
go: | ||
- 1.12.x | ||
script: | ||
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then ./fuzzit.sh fuzzing; fi | ||
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ./fuzzit.sh local-regression; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -xe | ||
|
||
## go-fuzz doesn't support modules for now, so ensure we do everything | ||
## in the old style GOPATH way | ||
export GO111MODULE="off" | ||
|
||
go get github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build | ||
|
||
wget -q -O fuzzitbin https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.24/fuzzit_Linux_x86_64 | ||
chmod a+x fuzzitbin | ||
|
||
for w in request response cookie url; do | ||
go-fuzz-build -libfuzzer -o fasthttp_$w.a ./fuzzit/$w/ | ||
clang -fsanitize=fuzzer fasthttp_$w.a -o fasthttp_$w | ||
|
||
./fuzzitbin create job --type $1 fasthttp/$w fasthttp_$w | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// +build gofuzz | ||
|
||
package fuzzit | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
func Fuzz(data []byte) int { | ||
c := fasthttp.AcquireCookie() | ||
defer fasthttp.ReleaseCookie(c) | ||
|
||
if err := c.ParseBytes(data); err != nil { | ||
return 0 | ||
} | ||
|
||
w := bytes.Buffer{} | ||
if _, err := c.WriteTo(&w); err != nil { | ||
return 0 | ||
} | ||
|
||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// +build gofuzz | ||
|
||
package fasthttp | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
|
||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
func Fuzz(data []byte) int { | ||
req := fasthttp.AcquireRequest() | ||
defer fasthttp.ReleaseRequest(req) | ||
|
||
if err := req.ReadLimitBody(bufio.NewReader(bytes.NewReader(data)), 1024*1024); err != nil { | ||
return 0 | ||
} | ||
|
||
w := bytes.Buffer{} | ||
if _, err := req.WriteTo(&w); err != nil { | ||
return 0 | ||
} | ||
|
||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// +build gofuzz | ||
|
||
package fuzzit | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
|
||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
func Fuzz(data []byte) int { | ||
res := fasthttp.AcquireResponse() | ||
defer fasthttp.ReleaseResponse(res) | ||
|
||
if err := res.ReadLimitBody(bufio.NewReader(bytes.NewReader(data)), 1024*1024); err != nil { | ||
return 0 | ||
} | ||
|
||
w := bytes.Buffer{} | ||
if _, err := res.WriteTo(&w); err != nil { | ||
return 0 | ||
} | ||
|
||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// +build gofuzz | ||
|
||
package fuzzit | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
func Fuzz(data []byte) int { | ||
u := fasthttp.AcquireURI() | ||
defer fasthttp.ReleaseURI(u) | ||
|
||
u.UpdateBytes(data) | ||
|
||
w := bytes.Buffer{} | ||
if _, err := u.WriteTo(&w); err != nil { | ||
return 0 | ||
} | ||
|
||
return 1 | ||
} |