feat(aa): add a string method to all rule struct.
This commit is contained in:
parent
e9fa0660f8
commit
5483668574
20 changed files with 337 additions and 34 deletions
|
|
@ -8,14 +8,27 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
tokALL = "all"
|
||||
tokALLOW = "allow"
|
||||
tokAUDIT = "audit"
|
||||
tokDENY = "deny"
|
||||
)
|
||||
|
||||
// Rule generic interface for all AppArmor rules
|
||||
type Rule interface {
|
||||
Less(other any) bool
|
||||
Equals(other any) bool
|
||||
String() string
|
||||
}
|
||||
|
||||
type Rules []Rule
|
||||
|
||||
func (r Rules) String() string {
|
||||
return renderTemplate("rules", r)
|
||||
}
|
||||
|
||||
|
||||
type RuleBase struct {
|
||||
Comment string
|
||||
NoNewPrivs bool
|
||||
|
|
@ -69,6 +82,10 @@ func (r RuleBase) Equals(other any) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (r RuleBase) String() string {
|
||||
return renderTemplate("comment", r)
|
||||
}
|
||||
|
||||
type Qualifier struct {
|
||||
Audit bool
|
||||
AccessType string
|
||||
|
|
@ -104,3 +121,7 @@ func (r *All) Less(other any) bool {
|
|||
func (r *All) Equals(other any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *All) String() string {
|
||||
return renderTemplate(tokALL, r)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue