feat(aa-log): minor improvment in rule generation & formatting.

This commit is contained in:
Alexandre Pujol 2024-09-26 22:15:46 +01:00
parent fbdf9cea64
commit 83bc7d3ade
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
7 changed files with 97 additions and 34 deletions

View file

@ -495,9 +495,15 @@ func (r rule) String() string {
}
func isAARE(str string) bool {
return strings.HasPrefix(str, "@") ||
strings.HasPrefix(str, "/") ||
strings.HasPrefix(str, "\"")
if len(str) < 1 {
return false
}
switch str[0] {
case '@', '/', '"':
return true
default:
return false
}
}
// Convert a slice of internal rules to a slice of ApparmorRule.
@ -652,8 +658,8 @@ done:
}
// Parse apparmor profile rules by paragraphs
func ParseRules(input string) ([]Rules, []string, error) {
paragraphRules := []Rules{}
func ParseRules(input string) (ParaRules, []string, error) {
paragraphRules := ParaRules{}
paragraphs := []string{}
for _, match := range regParagraph.FindAllStringSubmatch(input, -1) {