-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_parse_test.go
More file actions
42 lines (38 loc) · 971 Bytes
/
example_parse_test.go
File metadata and controls
42 lines (38 loc) · 971 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
41
42
package suricataparser_test
import (
"fmt"
"github.com/m-chrome/go-suricataparser"
)
func ExampleParseRule() {
rule, _ := suricataparser.ParseRule(
"alert http any any -> [1.1.1.1] any (sid:1; rev:1; gid:1; http_uri; msg:\"message\";)")
fmt.Println(rule)
fmt.Println(rule.Enabled)
fmt.Println(rule.Sid())
fmt.Println(rule.Rev())
fmt.Println(rule.Msg())
fmt.Println(rule.Action())
fmt.Println(rule.Header())
opts := rule.GetOptions("http_uri")
fmt.Println(opts[0])
rule.Enabled = false
fmt.Println(rule.Enabled)
fmt.Println(rule)
// Output:
// alert http any any -> [1.1.1.1] any (sid:1; rev:1; gid:1; http_uri; msg:"message";)
// true
// 1
// 1
// message
// alert
// http any any -> [1.1.1.1] any
// http_uri;
// false
// # alert http any any -> [1.1.1.1] any (sid:1; rev:1; gid:1; http_uri; msg:"message";)
}
func ExampleParseFile() {
rules, _ := suricataparser.ParseFile("test/test.rules")
fmt.Println(len(rules))
// Output:
// 2
}