mirror of
https://github.com/coredns/coredns.git
synced 2025-11-03 10:43:20 -05: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/rewrite/fuzz.go
Normal file
19
plugin/rewrite/fuzz.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package rewrite
|
||||
|
||||
import (
|
||||
"github.com/coredns/coredns/plugin/pkg/fuzz"
|
||||
|
||||
"github.com/mholt/caddy"
|
||||
)
|
||||
|
||||
// Fuzz fuzzes rewrite.
|
||||
func Fuzz(data []byte) int {
|
||||
c := caddy.NewTestController("dns", "rewrite edns0 subnet set 24 56")
|
||||
rules, err := rewriteParse(c)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
r := Rewrite{Rules: rules}
|
||||
|
||||
return fuzz.Do(r, data)
|
||||
}
|
||||
Reference in New Issue
Block a user