mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
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:
@@ -5,7 +5,7 @@
|
||||
# e.g.
|
||||
#
|
||||
# make -f Makefile.fuzz proxy
|
||||
#
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
@@ -13,7 +13,7 @@
|
||||
#$ go get github.com/dvyukov/go-fuzz/go-fuzz
|
||||
#$ 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/
|
||||
PLUGINS:=$(foreach f,$(FUZZ),$(subst plugin, ,$(f:/=))) # > /cache
|
||||
@@ -25,9 +25,15 @@ echo:
|
||||
|
||||
.PHONY: $(PLUGINS)
|
||||
$(PLUGINS): echo
|
||||
go-fuzz-build -tags fuzz $(REPO)/$(@)
|
||||
go-fuzz-build -tags fuzz $(REPO)/plugin/$(@)
|
||||
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
|
||||
clean:
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user