mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
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.
This commit is contained in:
19
plugin/proxy/fuzz.go
Normal file
19
plugin/proxy/fuzz.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"github.com/coredns/coredns/plugin/pkg/fuzz"
|
||||
|
||||
"github.com/mholt/caddy"
|
||||
)
|
||||
|
||||
// Fuzz fuzzes proxy.
|
||||
func Fuzz(data []byte) int {
|
||||
c := caddy.NewTestController("dns", "proxy . 8.8.8.8:53")
|
||||
up, err := NewStaticUpstreams(&c.Dispenser)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
p := &Proxy{Upstreams: &up}
|
||||
|
||||
return fuzz.Do(p, data)
|
||||
}
|
||||
Reference in New Issue
Block a user