mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 00:48:10 +01:00
feat(aa-log): Add support for encoded paths and profile names.
This commit is contained in:
parent
35a281d045
commit
e5c4ca400c
1 changed files with 16 additions and 1 deletions
|
@ -40,7 +40,10 @@ type AppArmorLog map[string]string
|
|||
// AppArmorLogs describes all apparmor log entries
|
||||
type AppArmorLogs []AppArmorLog
|
||||
|
||||
var quoted bool
|
||||
var (
|
||||
quoted bool
|
||||
isHexa = regexp.MustCompile("^[0-9A-Fa-f]+$")
|
||||
)
|
||||
|
||||
func splitQuoted(r rune) bool {
|
||||
if r == '"' {
|
||||
|
@ -56,6 +59,14 @@ func toQuote(str string) string {
|
|||
return str
|
||||
}
|
||||
|
||||
func decodeHex(str string) string {
|
||||
if isHexa.MatchString(str) {
|
||||
bs, _ := hex.DecodeString(str)
|
||||
return string(bs)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func removeDuplicateLog(logs []string) []string {
|
||||
list := []string{}
|
||||
keys := map[string]interface{}{"": true}
|
||||
|
@ -113,6 +124,10 @@ func NewApparmorLogs(file *os.File, profile string) AppArmorLogs {
|
|||
aa[kv[0]] = strings.Trim(kv[1], `"`)
|
||||
}
|
||||
}
|
||||
aa["profile"] = decodeHex(aa["profile"])
|
||||
if name, ok := aa["name"]; ok {
|
||||
aa["name"] = decodeHex(name)
|
||||
}
|
||||
aaLogs = append(aaLogs, aa)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue