-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzz.go
More file actions
40 lines (30 loc) · 735 Bytes
/
fuzz.go
File metadata and controls
40 lines (30 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package regexpbypass
import (
"fmt"
regexpb "github.com/sylvinus/regexpbypass/regexpbypass"
"regexp"
)
var acceptable = regexp.MustCompile(`^([abcd☺\|\$\.\^\[\]]+) ([abcdef☺\n]+)$`)
// TODO better starting corpus based on RE2 tests
func Fuzz(data []byte) int {
sdata := string(data)
m := acceptable.FindStringSubmatch(sdata)
if len(m) == 0 {
return -1
}
fmt.Println(m)
re, err := regexp.Compile(m[1])
if err != nil {
return 0
}
rebypass, errbypass := regexpb.Compile(m[1])
if err != errbypass {
panic("regexpbypass doesn't compile")
}
reMatches := re.MatchString(m[2])
reBypassMatches := rebypass.MatchString(m[2])
if reMatches != reBypassMatches {
panic("engine results differ!")
}
return 1
}