2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-03 07:45:50 +00:00

Add support for --show-matching-path and xattrs

The new option --show-matching-path shows a path that matches in the host
filesystem, to prove that the profile is indeed used.

Also, profiles' xattrs are now parsed into a dict and are taken in
consideration when looking for matching profiles.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
This commit is contained in:
Maxime Bélair
2025-05-13 16:38:36 +02:00
committed by Christian Boltz
parent db376c0458
commit b46f7a426c
9 changed files with 151 additions and 86 deletions

View File

@@ -18,7 +18,7 @@ from apparmor.regex import (
RE_PROFILE_START, parse_profile_start_line, re_match_include, RE_PROFILE_UNIX,
RE_PROFILE_PIVOT_ROOT,
re_match_include_parse, strip_parenthesis, strip_quotes, resolve_variables, expand_braces,
expand_var, expand_string)
expand_var, expand_string, re_print_dict, re_parse_dict)
from common_test import AATest, setup_aa, setup_all_loops
@@ -857,6 +857,27 @@ class TestInvalidExpandString(AATest):
expand_string(var, var_dict, seen_vars)
class TestRePrintDict(AATest):
tests = (
({'a': 'b'}, 'a=b'),
({'a': 'b', 'bb': 'cc'}, 'a=b bb=cc'),
({'z': 'c', 'y': 'b', 'x': 'a'}, 'x=a y=b z=c'),
)
def _run_test(self, params, expected):
self.assertEqual(re_print_dict(params), expected)
class TestReParseDict(AATest):
tests = (
('a=b', {'a': 'b'}),
(' a=bbb bb=cc', {'a': 'bbb', 'bb': 'cc'}),
)
def _run_test(self, params, expected):
self.assertEqual(re_parse_dict(params), expected)
setup_aa(aa)
setup_all_loops(__name__)
if __name__ == '__main__':