-
Notifications
You must be signed in to change notification settings - Fork 2
/
option.go
41 lines (34 loc) · 976 Bytes
/
option.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
package suricataparser
import "fmt"
const (
OptClasstype = "classtype"
OptGid = "gid"
OptMetadata = "metadata"
OptMsg = "msg"
OptRev = "rev"
OptSid = "sid"
OptReference = "reference"
)
// Option stores parsed option from rule - https://suricata.readthedocs.io/en/latest/rules/intro.html#rule-options
type Option struct {
Name string
Value string
}
func (o Option) String() string {
if o.Value == "" {
return fmt.Sprintf("%s;", o.Name)
}
return fmt.Sprintf("%s:%s;", o.Name, o.Value)
}
// NewOption returns rule metadata option
func NewOption(name, value string) Option {
return Option{Name: name, Value: value}
}
// NewEmptyOption returns rule metadata option with empty value
func NewEmptyOption(name string) Option {
return Option{Name: name, Value: ""}
}
// NewMsgOption returns rule message description option
func NewMsgOption(message string) Option {
return Option{Name: OptMsg, Value: fmt.Sprintf("\"%s\"", message)}
}