feat(aa): add rule constructors from internal parser.
This commit is contained in:
parent
ac9d6d859f
commit
163c5be61c
19 changed files with 456 additions and 75 deletions
|
|
@ -6,6 +6,7 @@ package aa
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
const NETWORK Kind = "network"
|
||||
|
|
@ -70,6 +71,28 @@ type Network struct {
|
|||
Protocol string
|
||||
}
|
||||
|
||||
func newNetwork(q Qualifier, rule rule) (Rule, error) {
|
||||
nType, protocol, domain := "", "", ""
|
||||
r := rule.GetSlice()
|
||||
if len(r) > 0 {
|
||||
domain = r[0]
|
||||
}
|
||||
if len(r) >= 2 {
|
||||
if slices.Contains(requirements[NETWORK]["type"], r[1]) {
|
||||
nType = r[1]
|
||||
} else if slices.Contains(requirements[NETWORK]["protocol"], r[1]) {
|
||||
protocol = r[1]
|
||||
}
|
||||
}
|
||||
return &Network{
|
||||
RuleBase: newBase(rule),
|
||||
Qualifier: q,
|
||||
Domain: domain,
|
||||
Type: nType,
|
||||
Protocol: protocol,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func newNetworkFromLog(log map[string]string) Rule {
|
||||
return &Network{
|
||||
RuleBase: newBaseFromLog(log),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue