mirror of https://github.com/status-im/whisper.git
Add fuzzing target
This commit is contained in:
parent
51d2371cf9
commit
eaa7a0f280
|
@ -1 +1,5 @@
|
|||
.idea
|
||||
suppressions
|
||||
corpus
|
||||
crashers
|
||||
whisperv6-fuzz.zip
|
||||
|
|
25
Makefile
25
Makefile
|
@ -2,6 +2,10 @@ SHELL = /bin/bash
|
|||
|
||||
GO111MODULE = on
|
||||
|
||||
clean:
|
||||
rm -rf crashers corpus suppressions whisperv6-fuzz.zip
|
||||
.PHONY: clean
|
||||
|
||||
test:
|
||||
go test -timeout 60s ./whisperv6/...
|
||||
go test -timeout 30s ./shhclient/...
|
||||
|
@ -16,5 +20,26 @@ vendor:
|
|||
install-dev:
|
||||
# a tool to vendor non-go files
|
||||
go get github.com/goware/modvendor@latest
|
||||
# a tool for fuzzing
|
||||
go get github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
|
||||
.PHONY: install-dev
|
||||
|
||||
# Couple things of note here are the use of the `ios` tag and disabling CGO
|
||||
# altogether.
|
||||
#
|
||||
# On our fork of go-ethereum, we've tagged `metrics/cpu.go` as so not to have
|
||||
# it built on the `ios` and `android` targets via a build tag. This diverges
|
||||
# from the upstream implementation, which does not have these tags.
|
||||
#
|
||||
# Metrics are captured through the use of a library, `gosigar`, which is an
|
||||
# abstraction for capturing this sort of info across different operating
|
||||
# systems. On Linux, for instance, it reads from the proc filesystem, but on
|
||||
# Darwin/OSX it'll use syscalls that need C.
|
||||
#
|
||||
# Disabling CGO here is also necessary, as the tool doesn't play well with CGO
|
||||
# at all. The tag and the environment variable are the combination that makes
|
||||
# this work.
|
||||
fuzz:
|
||||
CGO_ENABLED=0 go-fuzz-build -tags ios github.com/status-im/whisper/whisperv6
|
||||
go-fuzz -bin=whisperv6-fuzz.zip
|
||||
.PHONY: fuzz
|
||||
|
|
1
go.mod
1
go.mod
|
@ -8,6 +8,7 @@ require (
|
|||
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/deckarep/golang-set v1.7.1
|
||||
github.com/dvyukov/go-fuzz v0.0.0-20191022152526-8cb203812681 // indirect
|
||||
github.com/ethereum/go-ethereum v1.9.5
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -22,6 +22,8 @@ github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9r
|
|||
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
|
||||
github.com/dgrijalva/jwt-go v0.0.0-20170201225849-2268707a8f08/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/docker/docker v0.0.0-20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/dvyukov/go-fuzz v0.0.0-20191022152526-8cb203812681 h1:3WV5aRRj1ELP3RcLlBp/v0WJTuy47OQMkL9GIQq8QEE=
|
||||
github.com/dvyukov/go-fuzz v0.0.0-20191022152526-8cb203812681/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elastic/gosigar v0.0.0-20180330100440-37f05ff46ffa h1:o8OuEkracbk3qH6GvlI6XpEN1HTSxkzOG42xZpfDv/s=
|
||||
github.com/elastic/gosigar v0.0.0-20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs=
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// +build gofuzz
|
||||
|
||||
package whisperv6
|
||||
|
||||
func Fuzz(data []byte) int {
|
||||
if len(data) < 2 {
|
||||
return -1
|
||||
}
|
||||
|
||||
msg := &ReceivedMessage{Raw: data}
|
||||
msg.ValidateAndParse()
|
||||
|
||||
return 0
|
||||
}
|
Loading…
Reference in New Issue