-
Notifications
You must be signed in to change notification settings - Fork 3
/
fuzzer_options.go
81 lines (72 loc) · 1.63 KB
/
fuzzer_options.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package l9l4gfuzz
import (
"io"
"io/ioutil"
"text/template"
"time"
)
type FuzzerOption func(f *fuzzer) error
func WithTokenTranslator(tt *TokenTranslator) FuzzerOption {
return func(f *fuzzer) (err error) {
f.tokenTranslator = tt
return nil
}
}
func WithListenAddress(address string) FuzzerOption {
return func(f *fuzzer) (err error) {
f.listenAddress = address
return nil
}
}
func WithTimeout(timeout int) FuzzerOption {
return func(f *fuzzer) error {
f.timeout = time.Duration(timeout) * time.Second
return nil
}
}
func WithLDAPLogOutput(logoutput io.Writer) FuzzerOption {
return func(f *fuzzer) error {
f.ldapserverOutput = logoutput
return nil
}
}
func WithOutputChannel(outputChannel FuzzerChannel) FuzzerOption {
return func(f *fuzzer) error {
f.fuzzerOutputChannel = outputChannel
return nil
}
}
func WithRequestTemplate(filePath string) FuzzerOption {
return func(f *fuzzer) error {
if filePath == "" {
return nil
}
// #nosec We'll allow the CLI user to read his own files
fileBytes, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}
f.requestTemplate, err = template.New("request_template").Parse(string(fileBytes))
if err != nil {
return err
}
return nil
}
}
func WithPayloadTemplate(filePath string) FuzzerOption {
return func(f *fuzzer) error {
if filePath == "" {
return nil
}
// #nosec We'll allow the CLI user to read his own files
fileBytes, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}
f.payloadTemplate, err = template.New("payload_template").Parse(string(fileBytes))
if err != nil {
return err
}
return nil
}
}