feat(aa-log): add less & equals rule methods.

This commit is contained in:
Alexandre Pujol 2023-09-25 00:09:11 +01:00
parent 923bb66eba
commit e23e10d7b7
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
17 changed files with 394 additions and 86 deletions

View file

@ -12,17 +12,32 @@ import (
"strings"
"github.com/arduino/go-paths-helper"
"golang.org/x/exp/slices"
)
var (
regVariablesDef = regexp.MustCompile(`@{(.*)}\s*[+=]+\s*(.*)`)
regVariablesRef = regexp.MustCompile(`@{([^{}]+)}`)
// Default Apparmor magic directory: /etc/apparmor.d/.
MagicRoot = paths.New("/etc/apparmor.d")
)
type Variable struct {
Name string
Values []string
}
func (r Variable) Less(other Variable) bool {
if r.Name == other.Name {
return len(r.Values) < len(other.Values)
}
return r.Name < other.Name
}
func (r Variable) Equals(other Variable) bool {
return r.Name == other.Name && slices.Equal(r.Values, other.Values)
}
// DefaultTunables return a minimal working profile to build the profile
// It should not be used when loading file from /etc/apparmor.d