MCPcopy Create free account
hub / github.com/cel-expr/cel-go / FuzzChecker

Function FuzzChecker

fuzzing/fuzz_checker_test.go:26–52  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

24)
25
26func FuzzChecker(f *testing.F) {
27 f.Add([]byte{})
28 if env, err := getCELFuzzEnv(); err == nil {
29 if ast, issues := env.Parse("1 + 2 == 3 && 'abc'.startsWith('a')"); issues.Err() == nil {
30 if pe, err := cel.AstToParsedExpr(ast); err == nil {
31 if b, err := proto.Marshal(pe); err == nil {
32 f.Add(b)
33 }
34 }
35 }
36 }
37 f.Fuzz(func(t *testing.T, in []byte) {
38 var p exprpb.ParsedExpr
39 err := proto.UnmarshalOptions{
40 AllowPartial: true,
41 DiscardUnknown: true,
42 }.Unmarshal(in, &p)
43 if err != nil {
44 return
45 }
46 env, err := getCELFuzzEnv()
47 if err != nil {
48 panic(err)
49 }
50 _, _ = env.Check(cel.ParsedExprToAst(&p))
51 })
52}

Callers

nothing calls this directly

Calls 7

AstToParsedExprFunction · 0.92
ParsedExprToAstFunction · 0.92
getCELFuzzEnvFunction · 0.85
ErrMethod · 0.80
CheckMethod · 0.80
AddMethod · 0.65
ParseMethod · 0.65

Tested by

no test coverage detected