diff options
author | 2017-09-29 22:28:13 +0100 | |
---|---|---|
committer | 2017-09-29 22:28:13 +0100 | |
commit | 4276d29b81575992bf0c7525b4cb5716d493e913 (patch) | |
tree | 152994cf7cb251f9f46cb8c3b914cb413eda33de /Makefile.fuzz | |
parent | 23526aec1d933b6362c80eaa084749a794d43aca (diff) | |
download | coredns-4276d29b81575992bf0c7525b4cb5716d493e913.tar.gz coredns-4276d29b81575992bf0c7525b4cb5716d493e913.tar.zst coredns-4276d29b81575992bf0c7525b4cb5716d493e913.zip |
Add fuzzing infrastructure (#1118)
Fix file/fuzz.go build and docs in Makefile.fuzz
Each plugin can add a fuzz.go to join the fuzzing craze.
pkg/fuzz/do.go could be made a lot smarter, but is probably good enough
for starters.
$ make -f Makefile.fuzz <plugin>
will build with go-fuzz-build and then execute a go-fuzz run. Each
plugin's fuzz run uses a per-plugin directory to store the fuzz data.
Diffstat (limited to 'Makefile.fuzz')
-rw-r--r-- | Makefile.fuzz | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Makefile.fuzz b/Makefile.fuzz new file mode 100644 index 000000000..46358246b --- /dev/null +++ b/Makefile.fuzz @@ -0,0 +1,33 @@ +# Makefile for fuzzing +# +# Use go-fuzz and needs the tools installed. For each fuzz.go in a plugin's directory +# you can start the fuzzing with: make -f Makefile.fuzz <plugin> +# 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. +# +# Installing go-fuzz +#$ 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" + +FUZZ:=$(dir $(wildcard plugin/*/fuzz.go)) # plugin/cache/ +PLUGINS:=$(foreach f,$(FUZZ),$(subst plugin, ,$(f:/=))) # > /cache +PLUGINS:=$(foreach f,$(PLUGINS),$(subst /, ,$(f))) # > cache + +.PHONY: echo +echo: + @echo fuzz targets: $(PLUGINS) + +.PHONY: $(PLUGINS) +$(PLUGINS): echo + go-fuzz-build $(REPO)/$(@) + go-fuzz -bin=./$(@)-fuzz.zip -workdir=fuzz/$(@) + +.PHONY: clean +clean: + rm *-fuzz.zip |