aboutsummaryrefslogtreecommitdiff
path: root/projects/cel-go/fuzz_compile.go
diff options
context:
space:
mode:
Diffstat (limited to 'projects/cel-go/fuzz_compile.go')
-rw-r--r--projects/cel-go/fuzz_compile.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/projects/cel-go/fuzz_compile.go b/projects/cel-go/fuzz_compile.go
new file mode 100644
index 000000000..a7398da48
--- /dev/null
+++ b/projects/cel-go/fuzz_compile.go
@@ -0,0 +1,18 @@
+package cel
+
+func FuzzCompile(data []byte) int {
+ env, err := NewEnv()
+ if err != nil {
+ panic("impossible to create env")
+ }
+ ast, issues := env.Compile(string(data))
+ if issues != nil && issues.Err() != nil {
+ return 0
+ }
+ _, err = env.Program(ast)
+ if err != nil {
+ return 0
+ }
+
+ return 1
+}