mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-29 22:35:15 +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
|
// AppArmorLogs describes all apparmor log entries
|
||||||
type AppArmorLogs []AppArmorLog
|
type AppArmorLogs []AppArmorLog
|
||||||
|
|
||||||
var quoted bool
|
var (
|
||||||
|
quoted bool
|
||||||
|
isHexa = regexp.MustCompile("^[0-9A-Fa-f]+$")
|
||||||
|
)
|
||||||
|
|
||||||
func splitQuoted(r rune) bool {
|
func splitQuoted(r rune) bool {
|
||||||
if r == '"' {
|
if r == '"' {
|
||||||
|
@ -56,6 +59,14 @@ func toQuote(str string) string {
|
||||||
return str
|
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 {
|
func removeDuplicateLog(logs []string) []string {
|
||||||
list := []string{}
|
list := []string{}
|
||||||
keys := map[string]interface{}{"": true}
|
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[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)
|
aaLogs = append(aaLogs, aa)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue