diff --git a/projects/cel-go/fuzz_compile.go b/projects/cel-go/fuzz_compile.go index a7398da48..5c59d413d 100644 --- a/projects/cel-go/fuzz_compile.go +++ b/projects/cel-go/fuzz_compile.go @@ -1,7 +1,7 @@ package cel func FuzzCompile(data []byte) int { - env, err := NewEnv() + env, err := getCELFuzzEnv() if err != nil { panic("impossible to create env") } diff --git a/projects/cel-go/fuzz_env.go b/projects/cel-go/fuzz_env.go new file mode 100644 index 000000000..18cd2a46d --- /dev/null +++ b/projects/cel-go/fuzz_env.go @@ -0,0 +1,8 @@ +package cel + +// Create environment for running under Address sanitizer without timing out. +func getCELFuzzEnv() (*Env, error) { + // Very dense expressions (balanced trees) can cause address sanitizer to + // timeout even though they typically fail in under a second uninstrumented. + return NewEnv(ParserRecursionLimit(60)) +} diff --git a/projects/cel-go/fuzz_eval.go b/projects/cel-go/fuzz_eval.go index ee5b5482c..3aa250ab8 100644 --- a/projects/cel-go/fuzz_eval.go +++ b/projects/cel-go/fuzz_eval.go @@ -18,7 +18,12 @@ func FuzzEval(data []byte) int { for k, _ := range gen.Inputs { declares = append(declares, decls.NewVar(k, decls.String)) } - env, err := NewEnv(Declarations(declares...)) + env, err := getCELFuzzEnv() + if err != nil { + panic("impossible to create env") + } + + env, err = env.Extend(Declarations(declares...)) if err != nil { panic("impossible to create env") }