mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-01 23:05:11 +00:00
[14/38] Use FileRule and FileRuleset
Change aa.py to use FileRule and FileRuleset for parsing and saving profiles. In detail, this means: - add 'file' to the list of rule classes to enable it at various places - store file rules in aa[profile][hat]['file'] (not 'path' as before) to be consistent with the FileRule name - drop the no longer needed delete_path_duplicates() - this is now handled by FileRuleset like in all other rule classes. (same change in cleanprofile.py) - replace usage of RE_PROFILE_BARE_FILE_ENTRY and RE_PROFILE_PATH_ENTRY with FileRule.match() - drop write_path_rules() and write_paths() and replace them with the new write_file() function. - adjust several code sections to use write_file() and 'file' instead of 'path' FileRule doesn't drop optional keywords ('allow' and 'file'), therefore adjust cleanprof_test.out to the changed behaviour. (If someone insists on dropping optional keywords in aa-cleanprof, that's something for a future patch.) Also adjust the list of known failures in test-parser-simple-tests.py - switching to FileRule avoids several test failures (and introduces a few new ones ;-) IMPORTANT: This patch introduces a "brain split" which means - parsing and writing the profile and aa-cleanprof use the new location (aa[profile][hat]['file']) - aa-logprof and aa-genprof still save data to the old location (aa[profile][hat]['allow']['path']) and probably ask superfluous questions because there are no rules existing in the old location TL;DR: don't try aa-logprof or aa-genprof with only this patch applied. I know this isn't ideal, but still better than an even bigger and totally unreadable patch ;-) Acked-by: Steve Beattie <steve@nxnw.org>
This commit is contained in:
@@ -58,17 +58,9 @@ exception_not_raised = [
|
||||
'dbus/bad_regex_04.sd',
|
||||
'dbus/bad_regex_05.sd',
|
||||
'dbus/bad_regex_06.sd',
|
||||
'file/bad_append_1.sd',
|
||||
'file/bad_append_2.sd',
|
||||
'file/bad_embedded_spaces_1.sd',
|
||||
'file/bad_re_brace_1.sd',
|
||||
'file/bad_re_brace_2.sd',
|
||||
'file/bad_re_brace_3.sd',
|
||||
'file/file/bad_append_1.sd',
|
||||
'file/file/bad_embedded_spaces_1.sd',
|
||||
'file/file/owner/bad_3.sd',
|
||||
'file/file/owner/bad_5.sd',
|
||||
'file/owner/bad_3.sd',
|
||||
'file/owner/bad_5.sd',
|
||||
'mount/bad_opt_10.sd',
|
||||
'mount/bad_opt_11.sd',
|
||||
'mount/bad_opt_12.sd',
|
||||
@@ -194,17 +186,10 @@ exception_not_raised = [
|
||||
'xtrans/simple_bad_conflicting_x_11.sd',
|
||||
'xtrans/simple_bad_conflicting_x_12.sd',
|
||||
'xtrans/simple_bad_conflicting_x_13.sd',
|
||||
'xtrans/simple_bad_conflicting_x_14.sd',
|
||||
'xtrans/simple_bad_conflicting_x_15.sd',
|
||||
'xtrans/simple_bad_conflicting_x_1.sd',
|
||||
'xtrans/simple_bad_conflicting_x_2.sd',
|
||||
'xtrans/simple_bad_conflicting_x_3.sd',
|
||||
'xtrans/simple_bad_conflicting_x_4.sd',
|
||||
'xtrans/simple_bad_conflicting_x_5.sd',
|
||||
'xtrans/simple_bad_conflicting_x_6.sd',
|
||||
'xtrans/simple_bad_conflicting_x_7.sd',
|
||||
'xtrans/simple_bad_conflicting_x_8.sd',
|
||||
'xtrans/simple_bad_conflicting_x_9.sd',
|
||||
'xtrans/x-conflict.sd',
|
||||
]
|
||||
|
||||
@@ -217,11 +202,9 @@ unknown_line = [
|
||||
'file/ok_other_2.sd',
|
||||
'file/ok_other_3.sd',
|
||||
|
||||
# permissions before path
|
||||
# 'unsafe' keyword
|
||||
'file/file/front_perms_ok_1.sd',
|
||||
'file/front_perms_ok_1.sd',
|
||||
'profile/local/local_named_profile_ok1.sd',
|
||||
'profile/local/local_profile_ok1.sd',
|
||||
'xtrans/simple_ok_cx_1.sd',
|
||||
|
||||
# permissions before path and owner / audit {...} blocks
|
||||
@@ -273,6 +256,9 @@ syntax_failure = [
|
||||
'file/ok_5.sd', # Invalid mode UX
|
||||
'file/ok_2.sd', # Invalid mode RWM
|
||||
'file/ok_4.sd', # Invalid mode iX
|
||||
'file/ok_embedded_spaces_4.sd', # \-escaped space
|
||||
'file/file/ok_embedded_spaces_4.sd', # \-escaped space
|
||||
'file/ok_quoted_4.sd', # quoted string including \"
|
||||
'xtrans/simple_ok_pix_1.sd', # Invalid mode pIx
|
||||
'xtrans/simple_ok_pux_1.sd', # Invalid mode rPux
|
||||
|
||||
|
Reference in New Issue
Block a user