mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-12-26 06:58:00 +01:00
feat(aa-log): unify the isOwner function across features.
This commit is contained in:
parent
856c425dd5
commit
29a1642598
2 changed files with 5 additions and 6 deletions
|
@ -29,7 +29,7 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isOwner(log map[string]string) bool {
|
func IsOwner(log map[string]string) bool {
|
||||||
fsuid, hasFsUID := log["fsuid"]
|
fsuid, hasFsUID := log["fsuid"]
|
||||||
ouid, hasOuUID := log["ouid"]
|
ouid, hasOuUID := log["ouid"]
|
||||||
isDbus := strings.Contains(log["operation"], "dbus")
|
isDbus := strings.Contains(log["operation"], "dbus")
|
||||||
|
@ -98,7 +98,7 @@ func newFileFromLog(log map[string]string) Rule {
|
||||||
return &File{
|
return &File{
|
||||||
Base: newBaseFromLog(log),
|
Base: newBaseFromLog(log),
|
||||||
Qualifier: newQualifierFromLog(log),
|
Qualifier: newQualifierFromLog(log),
|
||||||
Owner: isOwner(log),
|
Owner: IsOwner(log),
|
||||||
Path: log["name"],
|
Path: log["name"],
|
||||||
Access: accesses,
|
Access: accesses,
|
||||||
Target: log["target"],
|
Target: log["target"],
|
||||||
|
@ -262,7 +262,7 @@ func newLinkFromLog(log map[string]string) Rule {
|
||||||
return &Link{
|
return &Link{
|
||||||
Base: newBaseFromLog(log),
|
Base: newBaseFromLog(log),
|
||||||
Qualifier: newQualifierFromLog(log),
|
Qualifier: newQualifierFromLog(log),
|
||||||
Owner: isOwner(log),
|
Owner: IsOwner(log),
|
||||||
Path: log["name"],
|
Path: log["name"],
|
||||||
Target: log["target"],
|
Target: log["target"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,12 +200,11 @@ func (aaLogs AppArmorLogs) String() string {
|
||||||
for _, log := range aaLogs {
|
for _, log := range aaLogs {
|
||||||
seen := map[string]bool{"apparmor": true}
|
seen := map[string]bool{"apparmor": true}
|
||||||
res.WriteString(state[log["apparmor"]])
|
res.WriteString(state[log["apparmor"]])
|
||||||
fsuid := log["fsuid"]
|
owner := aa.IsOwner(log)
|
||||||
ouid := log["ouid"]
|
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
if item, present := log[key]; present {
|
if item, present := log[key]; present {
|
||||||
if key == "name" && fsuid == ouid && !strings.Contains(log["operation"], "dbus") {
|
if key == "name" && owner {
|
||||||
res.WriteString(template[key] + " owner" + reset)
|
res.WriteString(template[key] + " owner" + reset)
|
||||||
}
|
}
|
||||||
if temp, present := template[key]; present {
|
if temp, present := template[key]; present {
|
||||||
|
|
Loading…
Reference in a new issue