summaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/hil/parser/fuzz.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hil/parser/fuzz.go')
-rw-r--r--vendor/github.com/hashicorp/hil/parser/fuzz.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hil/parser/fuzz.go b/vendor/github.com/hashicorp/hil/parser/fuzz.go
new file mode 100644
index 00000000..de954f38
--- /dev/null
+++ b/vendor/github.com/hashicorp/hil/parser/fuzz.go
@@ -0,0 +1,28 @@
+// +build gofuzz
+
+package parser
+
+import (
+ "github.com/hashicorp/hil/ast"
+ "github.com/hashicorp/hil/scanner"
+)
+
+// This is a fuzz testing function designed to be used with go-fuzz:
+// https://github.com/dvyukov/go-fuzz
+//
+// It's not included in a normal build due to the gofuzz build tag above.
+//
+// There are some input files that you can use as a seed corpus for go-fuzz
+// in the directory ./fuzz-corpus .
+
+func Fuzz(data []byte) int {
+ str := string(data)
+
+ ch := scanner.Scan(str, ast.Pos{Line: 1, Column: 1})
+ _, err := Parse(ch)
+ if err != nil {
+ return 0
+ }
+
+ return 1
+}