mirror of https://github.com/google/oss-fuzz.git
Set parser recursion limit for fuzz tests. (#8673)
Very large inputs that generate large ASTs can cause some of the sanitizers to timeout. Setting a smaller complexity limit should help filter out those cases. Co-authored-by: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>
This commit is contained in:
parent
820e17343c
commit
a442ef149d
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue