mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-15 07:54:17 +01:00
feat(aa): add basic rules getter
This commit is contained in:
parent
ad81c39e31
commit
3ad55927bf
@ -32,3 +32,24 @@ type Rules []Rule
|
|||||||
func (r Rules) String() string {
|
func (r Rules) String() string {
|
||||||
return renderTemplate("rules", r)
|
return renderTemplate("rules", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r Rules) Get(filter string) Rules {
|
||||||
|
res := make(Rules, 0)
|
||||||
|
for _, rule := range r {
|
||||||
|
if rule.Kind() == filter {
|
||||||
|
res = append(res, rule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Rules) GetVariables() []*Variable {
|
||||||
|
res := make([]*Variable, 0)
|
||||||
|
for _, rule := range r {
|
||||||
|
switch rule.(type) {
|
||||||
|
case *Variable:
|
||||||
|
res = append(res, rule.(*Variable))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user