From 2e2aa861d238e8889628a6bf9d433a57ceee7bce Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Mon, 23 May 2016 23:10:48 +0200 Subject: [PATCH] [1/9] add a named match group to RE_PROFILE_DBUS As a preparation for the DbusRule class, add a
match group to RE_PROFILE_DBUS. Also adjust test-regex_matches.py for the added group. Note: RE_PROFILE_DBUS is only used in aa.py, and only matches[0..2] are used. 0 and 1 are audit and allow/deny and 2 is and stays the whole rule (except audit and allow/deny). Therefore no aa.py changes are needed. Acked-by: Kshitij Gupta Acked-by: Seth Arnold --- utils/apparmor/regex.py | 2 +- utils/test/test-regex_matches.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/apparmor/regex.py b/utils/apparmor/regex.py index 01f7cc905..3fb48f9c8 100644 --- a/utils/apparmor/regex.py +++ b/utils/apparmor/regex.py @@ -46,7 +46,7 @@ RE_PROFILE_PATH_ENTRY = re.compile(RE_AUDIT_DENY + RE_OWNER + '(file\s+)?([\"@ RE_PROFILE_NETWORK = re.compile(RE_AUDIT_DENY + 'network(?P
\s+.*)?' + RE_COMMA_EOL) RE_PROFILE_CHANGE_HAT = re.compile('^\s*\^(\"??.+?\"??)' + RE_COMMA_EOL) RE_PROFILE_HAT_DEF = re.compile('^(?P\s*)(?P\^|hat\s+)(?P\"??.+?\"??)\s+((flags=)?\((?P.+)\)\s+)*\{' + RE_EOL) -RE_PROFILE_DBUS = re.compile(RE_AUDIT_DENY + '(dbus\s*,|dbus\s+[^#]*\s*,)' + RE_EOL) +RE_PROFILE_DBUS = re.compile(RE_AUDIT_DENY + '(dbus\s*,|dbus(?P
\s+[^#]*)\s*,)' + RE_EOL) RE_PROFILE_MOUNT = re.compile(RE_AUDIT_DENY + '((mount|remount|umount|unmount)(\s+[^#]*)?\s*,)' + RE_EOL) RE_PROFILE_SIGNAL = re.compile(RE_AUDIT_DENY + '(signal\s*,|signal(?P
\s+[^#]*)\s*,)' + RE_EOL) RE_PROFILE_PTRACE = re.compile(RE_AUDIT_DENY + '(ptrace\s*,|ptrace(?P
\s+[^#]*)\s*,)' + RE_EOL) diff --git a/utils/test/test-regex_matches.py b/utils/test/test-regex_matches.py index 3059ebf19..2b0c208a3 100644 --- a/utils/test/test-regex_matches.py +++ b/utils/test/test-regex_matches.py @@ -259,10 +259,10 @@ class AARegexDbus(AARegexTest): self.regex = aa.RE_PROFILE_DBUS tests = [ - (' dbus,', (None, None, 'dbus,', None)), - (' audit dbus,', ('audit', None, 'dbus,', None)), - (' dbus send member=no_comment,', (None, None, 'dbus send member=no_comment,', None)), - (' dbus send member=no_comment, # comment', (None, None, 'dbus send member=no_comment,', '# comment')), + (' dbus,', (None, None, 'dbus,', None, None)), + (' audit dbus,', ('audit', None, 'dbus,', None, None)), + (' dbus send member=no_comment,', (None, None, 'dbus send member=no_comment,', 'send member=no_comment', None)), + (' dbus send member=no_comment, # comment', (None, None, 'dbus send member=no_comment,', 'send member=no_comment', '# comment')), (' dbusdriver,', False), (' audit dbusdriver,', False),