aboutsummaryrefslogtreecommitdiffhomepage
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 0000000..de954f3
--- /dev/null
+++ b/vendor/github.com/hashicorp/hil/parser/fuzz.go
@@ -0,0 +1,28 @@
1// +build gofuzz
2
3package parser
4
5import (
6 "github.com/hashicorp/hil/ast"
7 "github.com/hashicorp/hil/scanner"
8)
9
10// This is a fuzz testing function designed to be used with go-fuzz:
11// https://github.com/dvyukov/go-fuzz
12//
13// It's not included in a normal build due to the gofuzz build tag above.
14//
15// There are some input files that you can use as a seed corpus for go-fuzz
16// in the directory ./fuzz-corpus .
17
18func Fuzz(data []byte) int {
19 str := string(data)
20
21 ch := scanner.Scan(str, ast.Pos{Line: 1, Column: 1})
22 _, err := Parse(ch)
23 if err != nil {
24 return 0
25 }
26
27 return 1
28}