Files
kubesphere/vendor/github.com/open-policy-agent/opa/ast/fuzz.go
hongming 9769357005 update
Signed-off-by: hongming <talonwan@yunify.com>
2020-03-20 02:16:11 +08:00

29 lines
445 B
Go

// +build gofuzz
package ast
import (
"regexp"
)
// nested { and [ tokens cause the parse time to explode.
// see: https://github.com/mna/pigeon/issues/75
var blacklistRegexp = regexp.MustCompile(`[{(\[]{5,}`)
func Fuzz(data []byte) int {
if blacklistRegexp.Match(data) {
return -1
}
str := string(data)
_, _, err := ParseStatements("", str)
if err == nil {
CompileModules(map[string]string{"": str})
return 1
}
return 0
}