feat(aa): add a string method to all rule struct.

This commit is contained in:
Alexandre Pujol 2024-04-23 21:26:09 +01:00
parent e9fa0660f8
commit 5483668574
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
20 changed files with 337 additions and 34 deletions

View file

@ -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)
}