mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
Add the aa-log helper.
This commit is contained in:
parent
2107e94b5c
commit
effc5eb9aa
25
root/usr/bin/aa-log
Executable file
25
root/usr/bin/aa-log
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# Review AppArmor generated messages
|
||||
# Copyright (C) 2021 Alexandre Pujol <alexandre@pujol.io>
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
|
||||
readonly LOGFILE=/var/log/audit/audit.log
|
||||
|
||||
# Parses AppArmor logs to hide unnecessary information and remove duplicates.
|
||||
_apparmor_log() {
|
||||
local state="$1" profile="${2}"
|
||||
grep -a "$state" "$LOGFILE" \
|
||||
| grep "profile=\"$profile.*\"" \
|
||||
| grep -v laddr \
|
||||
| sed -e 's/AVC //' \
|
||||
-e "s/apparmor=\"$state\"/$state/" \
|
||||
-e 's/type=msg=audit(.*): //' \
|
||||
-e 's/pid=.* comm/comm/' \
|
||||
-e 's/ fsuid.*//' \
|
||||
| awk '!x[$0]++'
|
||||
|
||||
}
|
||||
|
||||
_apparmor_log DENIED "$@"
|
||||
_apparmor_log ALLOWED "$@"
|
18
root/usr/share/zsh/site-functions/_aa-log.zsh
Normal file
18
root/usr/share/zsh/site-functions/_aa-log.zsh
Normal file
@ -0,0 +1,18 @@
|
||||
#compdef aa-log
|
||||
#autoload
|
||||
|
||||
_aa-log () {
|
||||
local IFS=$'\n'
|
||||
_values -C 'profile names' ${$(__aa_profiles):-""}
|
||||
}
|
||||
|
||||
__aa_profiles() {
|
||||
find -L /etc/apparmor.d -type f \
|
||||
| sed -e 's#/etc/apparmor.d/##' \
|
||||
-e '/abi/d' \
|
||||
-e '/abstractions/d' \
|
||||
-e '/local/d' \
|
||||
| sort
|
||||
}
|
||||
|
||||
_aa-log
|
Loading…
Reference in New Issue
Block a user