Fuzzing: add more fuzzing targets (#2402)
* Add more fuzzing Signed-off-by: Miek Gieben <miek@miek.nl> * More fuzzing targets Signed-off-by: Miek Gieben <miek@miek.nl> * Fuzzing: add more fuzzing targets Also add Corefile fuzzing. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
235aac32ad
commit
14f8b5d75a
4 changed files with 47 additions and 3 deletions
|
@ -5,7 +5,7 @@
|
||||||
# e.g.
|
# e.g.
|
||||||
#
|
#
|
||||||
# make -f Makefile.fuzz proxy
|
# make -f Makefile.fuzz proxy
|
||||||
#
|
#
|
||||||
# Each plugin that wants to join the fuzzing fray only needs to add a fuzz.go that calls
|
# Each plugin that wants to join the fuzzing fray only needs to add a fuzz.go that calls
|
||||||
# the plugins's ServeDNS and used the plugin/pkg/fuzz for the Do function.
|
# the plugins's ServeDNS and used the plugin/pkg/fuzz for the Do function.
|
||||||
#
|
#
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#$ go get github.com/dvyukov/go-fuzz/go-fuzz
|
#$ go get github.com/dvyukov/go-fuzz/go-fuzz
|
||||||
#$ go get github.com/dvyukov/go-fuzz/go-fuzz-build
|
#$ go get github.com/dvyukov/go-fuzz/go-fuzz-build
|
||||||
|
|
||||||
REPO:="github.com/coredns/coredns/plugin"
|
REPO:="github.com/coredns/coredns"
|
||||||
|
|
||||||
FUZZ:=$(dir $(wildcard plugin/*/fuzz.go)) # plugin/cache/
|
FUZZ:=$(dir $(wildcard plugin/*/fuzz.go)) # plugin/cache/
|
||||||
PLUGINS:=$(foreach f,$(FUZZ),$(subst plugin, ,$(f:/=))) # > /cache
|
PLUGINS:=$(foreach f,$(FUZZ),$(subst plugin, ,$(f:/=))) # > /cache
|
||||||
|
@ -25,9 +25,15 @@ echo:
|
||||||
|
|
||||||
.PHONY: $(PLUGINS)
|
.PHONY: $(PLUGINS)
|
||||||
$(PLUGINS): echo
|
$(PLUGINS): echo
|
||||||
go-fuzz-build -tags fuzz $(REPO)/$(@)
|
go-fuzz-build -tags fuzz $(REPO)/plugin/$(@)
|
||||||
go-fuzz -bin=./$(@)-fuzz.zip -workdir=fuzz/$(@)
|
go-fuzz -bin=./$(@)-fuzz.zip -workdir=fuzz/$(@)
|
||||||
|
|
||||||
|
.PHONY: corefile
|
||||||
|
corefile:
|
||||||
|
go-fuzz-build -tags fuzz $(REPO)/test
|
||||||
|
go-fuzz -bin=./test-fuzz.zip -workdir=fuzz/$(@)
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm *-fuzz.zip
|
rm *-fuzz.zip
|
||||||
|
|
13
plugin/chaos/fuzz.go
Normal file
13
plugin/chaos/fuzz.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// +build fuzz
|
||||||
|
|
||||||
|
package chaos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/coredns/coredns/plugin/pkg/fuzz"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Fuzz fuzzes cache.
|
||||||
|
func Fuzz(data []byte) int {
|
||||||
|
c := Chaos{}
|
||||||
|
return fuzz.Do(c, data)
|
||||||
|
}
|
13
plugin/whoami/fuzz.go
Normal file
13
plugin/whoami/fuzz.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// +build fuzz
|
||||||
|
|
||||||
|
package whoami
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/coredns/coredns/plugin/pkg/fuzz"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Fuzz fuzzes cache.
|
||||||
|
func Fuzz(data []byte) int {
|
||||||
|
w := Whoami{}
|
||||||
|
return fuzz.Do(w, data)
|
||||||
|
}
|
12
test/fuzz_corefile.go
Normal file
12
test/fuzz_corefile.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// +build fuzz
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
// Fuzz fuzzes a corefile.
|
||||||
|
func Fuzz(data []byte) int {
|
||||||
|
_, _, _, err := CoreDNSServerAndPorts(string(data))
|
||||||
|
if err != nil {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue