Hallo, this patch replaces RE_PROFILE_START with RE_PROFILE_START_2 and adjusts all code section that used RE_PROFILE_START_2.
The only real change is that test_get_flags_invalid_01 and test_get_flags_invalid_02 now expect AppArmorException instead of AppArmorBug. This is another patch I propose for trunk and 2.9. For easier reviewing, you can download my pending patches as tarball: www.cboltz.de/tmp/dl/aa-patches.tar.gz Happy reviewing ;-) [ 24-replace-RE_PROFILE_START.diff ] === modified file utils/apparmor/regex.py --- utils/apparmor/regex.py 2015-03-15 22:58:35.677048807 +0100 +++ utils/apparmor/regex.py 2015-03-15 23:57:28.485404639 +0100 @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # Copyright (C) 2013 Kshitij Gupta <kgupta8...@gmail.com> -# Copyright (C) 2014 Christian Boltz <appar...@cboltz.de> +# Copyright (C) 2014-2015 Christian Boltz <appar...@cboltz.de> # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public @@ -26,7 +26,6 @@ RE_EOL = '\s*(?P<comment>#.*?)?\s*$' # optional whitespace, optional <comment>, optional whitespace, end of the line RE_COMMA_EOL = '\s*,' + RE_EOL # optional whitespace, comma + RE_EOL -RE_PROFILE_START = re.compile('^\s*("?(/.+?)"??|(profile\s+"?(.+?)"??))\s+((flags=)?\((.+)\)\s+)?\{' + RE_EOL) RE_PROFILE_END = re.compile('^\s*\}' + RE_EOL) RE_PROFILE_CAP = re.compile(RE_AUDIT_DENY + 'capability(?P<capability>(\s+\S+)+)?' + RE_COMMA_EOL) RE_PROFILE_LINK = re.compile(RE_AUDIT_DENY + 'link\s+(((subset)|(<=))\s+)?([\"\@\/].*?"??)\s+->\s*([\"\@\/].*?"??)' + RE_COMMA_EOL) @@ -62,7 +61,7 @@ -RE_PROFILE_START_2 = re.compile( +RE_PROFILE_START = re.compile( '^(?P<leadingspace>\s*)' + '(' + '(?P<plainprofile>(/\S+|"[^"]+"))' + # just a path @@ -73,7 +72,7 @@ RE_EOL) def parse_profile_start_line(line, filename): - matches = RE_PROFILE_START_2.search(line) + matches = RE_PROFILE_START.search(line) if not matches: raise AppArmorBug('The given line from file %(filename)s is not the start of a profile: %(line)s' % { 'filename': filename, 'line': line } ) === modified file utils/test/test-aa.py --- utils/test/test-aa.py 2015-03-15 23:53:13.286501947 +0100 +++ utils/test/test-aa.py 2015-03-15 23:57:28.486404579 +0100 @@ -92,10 +92,10 @@ self._test_get_flags('/foo flags=(complain, audit)', 'complain, audit') def test_get_flags_invalid_01(self): - with self.assertRaises(AppArmorBug): + with self.assertRaises(AppArmorException): self._test_get_flags('/foo ()', None) def test_get_flags_invalid_02(self): - with self.assertRaises(AppArmorBug): + with self.assertRaises(AppArmorException): self._test_get_flags('/foo flags=()', None) def test_get_flags_invalid_03(self): with self.assertRaises(AppArmorException): === modified file utils/test/test-regex_matches.py --- utils/test/test-regex_matches.py 2015-03-15 22:58:35.677048807 +0100 +++ utils/test/test-regex_matches.py 2015-03-15 23:57:28.486404579 +0100 @@ -14,7 +14,7 @@ from common_test import AATest, setup_all_tests from apparmor.common import AppArmorBug -from apparmor.regex import strip_quotes, parse_profile_start_line, RE_PROFILE_START_2 +from apparmor.regex import strip_quotes, parse_profile_start_line, RE_PROFILE_START class AARegexTest(AATest): @@ -393,10 +393,10 @@ ] class AANamedRegexProfileStart_2(AANamedRegexTest): - '''Tests for RE_PROFILE_START_2''' + '''Tests for RE_PROFILE_START''' def setUp(self): - self.regex = RE_PROFILE_START_2 + self.regex = RE_PROFILE_START tests = [ ('/bin/foo ', False), # no '{' Regards, Christian Boltz -- > Verschlüsselt auf diese Mailingliste? Das solltest Du mal kurz > begründen. Vielleicht 'ne Gegenmaßnahme gegen die Datensammelwut von NSA und Co. Der Adressat kanns lesen und sonst weiß keiner, was drinsteht und wer gemeint ist. ;-) [> Johannes Diestelmann und Rolf Muth in opensuse-de] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor