feat(aa-log): add less & equals rule methods.
This commit is contained in:
parent
923bb66eba
commit
e23e10d7b7
17 changed files with 394 additions and 86 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue