From 05de39d92a221751fc6e6becd0a4064bdd18ee34 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sat, 25 May 2024 22:03:16 +0100 Subject: [PATCH] feat(aa): improve comment generation from log map. --- pkg/aa/base.go | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/pkg/aa/base.go b/pkg/aa/base.go index 7b2bb127a..0e04bc2c7 100644 --- a/pkg/aa/base.go +++ b/pkg/aa/base.go @@ -18,38 +18,27 @@ type RuleBase struct { Optional bool } - func newRuleFromLog(log map[string]string) RuleBase { - fileInherit := false + comment := "" + fileInherit, noNewPrivs, optional := false, false, false + if log["operation"] == "file_inherit" { fileInherit = true } - - noNewPrivs := false - optional := false - msg := "" - switch log["error"] { - case "-1": + if log["error"] == "-1" { if strings.Contains(log["info"], "optional:") { optional = true - msg = strings.Replace(log["info"], "optional: ", "", 1) + comment = strings.Replace(log["info"], "optional: ", "", 1) } else { noNewPrivs = true } - case "-13": - ignoreProfileInfo := []string{"namespace", "disconnected path"} - for _, info := range ignoreProfileInfo { - if strings.Contains(log["info"], info) { - break - } - } - msg = log["info"] - default: } - + if log["info"] != "" { + comment += " " + log["info"] + } return RuleBase{ IsLineRule: false, - Comment: msg, + Comment: comment, NoNewPrivs: noNewPrivs, FileInherit: fileInherit, Optional: optional,