aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.fuzz12
-rw-r--r--plugin/chaos/fuzz.go13
-rw-r--r--plugin/whoami/fuzz.go13
-rw-r--r--test/fuzz_corefile.go12
4 files changed, 47 insertions, 3 deletions
diff --git a/Makefile.fuzz b/Makefile.fuzz
index 2a97d67f0..f9c22db4b 100644
--- a/Makefile.fuzz
+++ b/Makefile.fuzz
@@ -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
diff --git a/plugin/chaos/fuzz.go b/plugin/chaos/fuzz.go
new file mode 100644
index 000000000..f0e23b083
--- /dev/null
+++ b/plugin/chaos/fuzz.go
@@ -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)
+}
diff --git a/plugin/whoami/fuzz.go b/plugin/whoami/fuzz.go
new file mode 100644
index 000000000..d9bbcee2b
--- /dev/null
+++ b/plugin/whoami/fuzz.go
@@ -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)
+}
diff --git a/test/fuzz_corefile.go b/test/fuzz_corefile.go
new file mode 100644
index 000000000..0abb9d6b3
--- /dev/null
+++ b/test/fuzz_corefile.go
@@ -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
+}