mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
aa-log: cosmetic.
This commit is contained in:
parent
0294ef3270
commit
7f7a2e5eda
@ -33,8 +33,7 @@ type AppArmorLogs []AppArmorLog
|
|||||||
|
|
||||||
func removeDuplicateLog(logs []string) []string {
|
func removeDuplicateLog(logs []string) []string {
|
||||||
list := []string{}
|
list := []string{}
|
||||||
keys := make(map[string]interface{})
|
keys := map[string]interface{}{"": true}
|
||||||
keys[""] = true
|
|
||||||
for _, log := range logs {
|
for _, log := range logs {
|
||||||
if _, v := keys[log]; !v {
|
if _, v := keys[log]; !v {
|
||||||
keys[log] = true
|
keys[log] = true
|
||||||
@ -96,11 +95,13 @@ func (aaLogs AppArmorLogs) String() string {
|
|||||||
"DENIED": BoldRed + "DENIED " + Reset,
|
"DENIED": BoldRed + "DENIED " + Reset,
|
||||||
"ALLOWED": BoldGreen + "ALLOWED" + Reset,
|
"ALLOWED": BoldGreen + "ALLOWED" + Reset,
|
||||||
}
|
}
|
||||||
|
// Order of impression
|
||||||
keys := []string{
|
keys := []string{
|
||||||
"profile", "operation", "name", "info", "comm", "laddr",
|
"profile", "operation", "name", "info", "comm", "laddr",
|
||||||
"lport", "faddr", "fport", "family", "sock_type", "protocol",
|
"lport", "faddr", "fport", "family", "sock_type", "protocol",
|
||||||
"requested_mask", "denied_mask", // "fsuid", "ouid", "FSUID", "OUID",
|
"requested_mask", "denied_mask", "signal", "peer", // "fsuid", "ouid", "FSUID", "OUID",
|
||||||
}
|
}
|
||||||
|
// Optional colors template to use
|
||||||
colors := map[string]string{
|
colors := map[string]string{
|
||||||
"profile": FgBlue,
|
"profile": FgBlue,
|
||||||
"operation": FgYellow,
|
"operation": FgYellow,
|
||||||
@ -109,8 +110,8 @@ func (aaLogs AppArmorLogs) String() string {
|
|||||||
"denied_mask": "denied_mask=" + BoldRed,
|
"denied_mask": "denied_mask=" + BoldRed,
|
||||||
}
|
}
|
||||||
for _, log := range aaLogs {
|
for _, log := range aaLogs {
|
||||||
|
seen := map[string]bool{"apparmor": true}
|
||||||
res += state[log["apparmor"]]
|
res += state[log["apparmor"]]
|
||||||
delete(log, "apparmor")
|
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
if log[key] != "" {
|
if log[key] != "" {
|
||||||
@ -119,13 +120,15 @@ func (aaLogs AppArmorLogs) String() string {
|
|||||||
} else {
|
} else {
|
||||||
res += " " + key + "=" + log[key]
|
res += " " + key + "=" + log[key]
|
||||||
}
|
}
|
||||||
delete(log, key)
|
seen[key] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range log {
|
for key, value := range log {
|
||||||
|
if !seen[key] {
|
||||||
res += " " + key + "=" + value
|
res += " " + key + "=" + value
|
||||||
}
|
}
|
||||||
|
}
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
@ -139,12 +142,13 @@ func main() {
|
|||||||
|
|
||||||
file, err := os.Open(LogFile)
|
file, err := os.Open(LogFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err)
|
||||||
return
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
fmt.Println("Error closing file:", err)
|
fmt.Println("Error closing file:", err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module gitlab.com/roddhjav/apparmor.d
|
module github.com/roddhjav/apparmor.d
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
Loading…
Reference in New Issue
Block a user