diff --git a/utils/apparmor/profile_storage.py b/utils/apparmor/profile_storage.py index a64accaa3..990225553 100644 --- a/utils/apparmor/profile_storage.py +++ b/utils/apparmor/profile_storage.py @@ -201,7 +201,9 @@ class ProfileStorage: return data @classmethod - def parse_profile_start(cls, line, file, lineno, profile, hat): + def parse(cls, line, file, lineno, profile, hat): + ''' parse a profile start line (using parse_profile_startline()) and convert it to a ProfileStorage ''' + matches = parse_profile_start_line(line, file) if profile: # we are inside a profile, so we expect a child profile @@ -227,30 +229,14 @@ class ProfileStorage: hat = profile pps_set_hat_external = False - attachment = matches['attachment'] - flags = matches['flags'] - xattrs = matches['xattrs'] - - return (profile, hat, attachment, xattrs, flags, pps_set_hat_external) - - @classmethod - def parse(cls, line, file, lineno, profile, hat): - ''' parse a profile start line (using parse_profile_startline()) and convert it to a ProfileStorage ''' - - (profile, hat, attachment, xattrs, flags, pps_set_hat_external) = cls.parse_profile_start(line, file, lineno, profile, hat) - prof_storage = ProfileStorage(profile, hat, 'ProfileStorage.parse()') - if attachment: - prof_storage['attachment'] = attachment - - if pps_set_hat_external: - prof_storage['external'] = True - prof_storage['name'] = profile prof_storage['filename'] = file - prof_storage['xattrs'] = xattrs - prof_storage['flags'] = flags + prof_storage['external'] = pps_set_hat_external + prof_storage['attachment'] = matches['attachment'] or '' + prof_storage['flags'] = matches['flags'] + prof_storage['xattrs'] = matches['xattrs'] return (profile, hat, prof_storage) diff --git a/utils/test/test-profile-storage.py b/utils/test/test-profile-storage.py index 10cfd4c56..7b6800a53 100644 --- a/utils/test/test-profile-storage.py +++ b/utils/test/test-profile-storage.py @@ -152,10 +152,6 @@ class AaTest_parse_profile_start(AATest): ] def _run_test(self, params, expected): - parsed = ProfileStorage.parse_profile_start(params[0], 'somefile', 1, params[1], params[2]) - - self.assertEqual(parsed, expected) - (profile, hat, prof_storage) = ProfileStorage.parse(params[0], 'somefile', 1, params[1], params[2]) self.assertEqual(profile, expected[0]) @@ -177,9 +173,6 @@ class AaTest_parse_profile_start_errors(AATest): ] def _run_test(self, params, expected): - with self.assertRaises(expected): - ProfileStorage.parse_profile_start(params[0], 'somefile', 1, params[1], params[2]) - with self.assertRaises(expected): ProfileStorage.parse(params[0], 'somefile', 1, params[1], params[2])