mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
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.
This commit is contained in:
parent
d29bf02d7b
commit
c4db85c66a
2 changed files with 3 additions and 3 deletions
|
@ -138,7 +138,7 @@ class IncludeRule(BaseRule):
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
if os.path.isdir(full_path):
|
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):
|
if is_skippable_file(path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ class IncludeFullPathsTest(AATest):
|
||||||
os.mkdir(empty_dir, 0o755)
|
os.mkdir(empty_dir, 0o755)
|
||||||
|
|
||||||
tests = [
|
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 <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"', ['@@/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'] ),
|
('include "/foo/bar"', ['/foo/bar'] ),
|
||||||
|
@ -376,7 +376,7 @@ class IncludeFullPathsTest(AATest):
|
||||||
exp2.append(path.replace('@@', self.profile_dir))
|
exp2.append(path.replace('@@', self.profile_dir))
|
||||||
|
|
||||||
obj = IncludeRule._parse(params)
|
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 --- #
|
## --- tests for IncludeRuleset --- #
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue