Skip to content

Commit

Permalink
Update fuzzing (#297)
Browse files Browse the repository at this point in the history
* fix fuzz testing

- closes #288
- add fuzz testing to CI

Signed-off-by: Marko Baricevic <[email protected]>

* test ci

* fix yml

* remove fuzzing from ci

* add workflows
  • Loading branch information
tac0turtle authored Dec 18, 2019
1 parent 01b51bd commit dcefe5e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 26 deletions.
16 changes: 13 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
version: 2
jobs:
build:
version: 2.1

executors:
golang:
docker:
- image: circleci/golang:1.13

jobs:
test_cover:
executor: golang
steps:
- checkout
- restore_cache:
Expand All @@ -20,3 +24,9 @@ jobs:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"

workflows:
version: 2
test-suite:
jobs:
- test_cover
30 changes: 7 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
GOTOOLS = \
github.com/golangci/golangci-lint/cmd/golangci-lint
GOTOOLS_CHECK = golangci-lint

all: check_tools test

Expand All @@ -17,19 +14,7 @@ install:
########################################
### Tools & dependencies

check_tools:
@# https://stackoverflow.com/a/25668869
@echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"

get_tools:
@echo "--> Installing tools"
go get -v $(GOTOOLS)

update_tools:
@echo "--> Updating tools"
@go get -u -v $(GOTOOLS)

include tools.mk

########################################
### Testing
Expand All @@ -42,18 +27,17 @@ gofuzz_binary:
rm -rf tests/fuzz/binary/crashers/
rm -rf tests/fuzz/binary/suppressions/
go run tests/fuzz/binary/init-corpus/main.go --corpus-parent=tests/fuzz/binary
# TODO: update when https://github.com/dvyukov/go-fuzz/issues/195 is resolved
GO111MODULE=off go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/binary
GO111MODULE=off go-fuzz -bin=./fuzz_binary-fuzz.zip -workdir=tests/fuzz/binary
go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/binary
go-fuzz -bin=./fuzzbinary-fuzz.zip -workdir=tests/fuzz/binary
rm -rf ./fuzzbinary-fuzz.zip

gofuzz_json:
rm -rf tests/fuzz/json/corpus/
rm -rf tests/fuzz/json/crashers/
rm -rf tests/fuzz/json/suppressions/
# TODO: update when https://github.com/dvyukov/go-fuzz/issues/195 is resolved
GO111MODULE=off go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/json
GO111MODULE=off go-fuzz -bin=./fuzz_json-fuzz.zip -workdir=tests/fuzz/json

go-fuzz-build github.com/tendermint/go-amino/tests/fuzz/json
go-fuzz -bin=./fuzzjson-fuzz.zip -workdir=tests/fuzz/json
rm -rf ./fuzzjson-fuzz.zip

########################################
### Formatting, linting, and vetting
Expand Down
Binary file added fuzzjson-fuzz.zip
Binary file not shown.
46 changes: 46 additions & 0 deletions tools.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
###
# Find OS and Go environment
# GO contains the Go binary
# FS contains the OS file separator
###
ifeq ($(OS),Windows_NT)
GO := $(shell where go.exe 2> NUL)
FS := "\\"
else
GO := $(shell command -v go 2> /dev/null)
FS := "/"
endif

ifeq ($(GO),)
$(error could not find go. Is it in PATH? $(GO))
endif

all: tools

tools: go-fuzz go-fuzz-build

TOOLS_DESTDIR ?= $(GOPATH)/bin

GOFUZZ = $(TOOLS_DESTDIR)/go-fuzz
GOFUZZ_BUILD = $(TOOLS_DESTDIR)/go-fuzz-build

# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
# go.{mod, sum} files.
#
# ref: https://github.com/golang/go/issues/30515
go-fuzz: $(GOFUZZ)
$(GOFUZZ):
@echo "Installing go-fuzz..."
@(cd /tmp && go get -u github.com/dvyukov/go-fuzz/go-fuzz)

go-fuzz-build: $(GOFUZZ_BUILD)
$(GOFUZZ_BUILD):
@echo "Installing go-fuzz-build..."
@(cd /tmp && go get -u github.com/dvyukov/go-fuzz/go-fuzz-build)

tools-clean:
rm -f $(GOFUZZ_BUILD) $(GOFUZZ)
rm -f tools-stamp

.PHONY: all tools tools-clean

0 comments on commit dcefe5e

Please sign in to comment.