mirror of
https://github.com/coredns/coredns.git
synced 2025-11-14 16:02:16 -05:00
This feature introduce continuous fuzzing with the following features: * Ruzzing: fuzz-targets are run continuously on master ( the fuzzers are updated every time new code is pushed to master) * Regresion: In addition to unit-tests travis runs all fuzz targets through the generated corpus to catch bugs early on in the CI process before merge.
53 lines
1.4 KiB
Makefile
53 lines
1.4 KiB
Makefile
# 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 forward
|
|
#
|
|
# 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"
|
|
# set LIBFUZZER=YES to build libfuzzer compatible targets
|
|
|
|
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
|
|
ifeq ($(LIBFUZZER), YES)
|
|
go-fuzz-build -tags fuzz -libfuzzer -o $(@).a ./plugin/$(@)
|
|
clang -fsanitize=fuzzer $(@).a -o $(@)
|
|
else
|
|
go-fuzz-build -tags fuzz $(REPO)/plugin/$(@)
|
|
go-fuzz -bin=./$(@)-fuzz.zip -workdir=fuzz/$(@)
|
|
endif
|
|
|
|
|
|
.PHONY: corefile
|
|
corefile:
|
|
ifeq ($(LIBFUZZER), YES)
|
|
go-fuzz-build -tags fuzz -libfuzzer -o $(@).a ./test
|
|
clang -fsanitize=fuzzer $(@).a -o $(@)
|
|
else
|
|
go-fuzz-build -tags fuzz $(REPO)/test
|
|
go-fuzz -bin=./test-fuzz.zip -workdir=fuzz/$(@)
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm *-fuzz.zip
|