2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

Merge branch 'cboltz-include-sort' into 'master'

IncludeRule: sort files in included directory

... instead of relying on the filesystem(!) ordering, which will look
random to both users and unittests.

Also partially revert the test changes from
c5a7bcd50e /
https://gitlab.com/apparmor/apparmor/-/merge_requests/548 -
sorting the result only in the tests is a bad idea.

See merge request apparmor/apparmor!552

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
Christian Boltz
2020-06-03 11:31:10 +00:00
2 changed files with 3 additions and 3 deletions

View File

@@ -138,7 +138,7 @@ class IncludeRule(BaseRule):
files = []
if os.path.isdir(full_path):
for path in os.listdir(full_path):
for path in sorted(os.listdir(full_path)):
if is_skippable_file(path):
continue

View File

@@ -360,7 +360,7 @@ class IncludeFullPathsTest(AATest):
os.mkdir(empty_dir, 0o755)
tests = [
# @@ will be replaced with self.profile_dir; if multiple entries, need to be sorted
# @@ will be replaced with self.profile_dir
('include <abstractions/base>', ['@@/abstractions/base'] ),
# ('include "foo"', ['@@/foo'] ), # TODO: adjust logic to honor quoted vs. magic paths (and allow quoted relative paths in re_match_include_parse())
('include "/foo/bar"', ['/foo/bar'] ),
@@ -376,7 +376,7 @@ class IncludeFullPathsTest(AATest):
exp2.append(path.replace('@@', self.profile_dir))
obj = IncludeRule._parse(params)
self.assertEqual(sorted(obj.get_full_paths(self.profile_dir)), exp2)
self.assertEqual(obj.get_full_paths(self.profile_dir), exp2)
## --- tests for IncludeRuleset --- #