2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-05 08:45:22 +00:00

[37/38] Drop severity rank() dispatcher

rank() in severity.py is a dispatcher that calls the needed function
(rank_path(), rank_capability()) based on the parameter. Since all
calling code knows what rule type it is handling, this dispatcher is
superfluous - the calling code can call rank_path() or rank_capability()
directly.

This patch drops rank() and switches the remaining users of rank() to
call the rank_*() functions directly. For the tests, this means to drop
the CAP_ prefix because rank_capability doesn't expect this prefix.


Acked-by: Steve Beattie <steve@nxnw.org>
This commit is contained in:
Christian Boltz
2016-10-01 20:15:45 +02:00
parent 265fd4a708
commit 5dbb283af5
3 changed files with 5 additions and 17 deletions

View File

@@ -25,13 +25,13 @@ class SeverityBaseTest(AATest):
def AASetup(self):
self.sev_db = severity.Severity('severity.db', 'unknown')
def _simple_severity_test(self, path, expected_rank):
rank = self.sev_db.rank(path)
def _capability_severity_test(self, cap, expected_rank):
rank = self.sev_db.rank_capability(cap)
self.assertEqual(rank, expected_rank,
'expected rank %s, got %s' % (expected_rank, rank))
def _simple_severity_w_perm(self, path, perm, expected_rank):
rank = self.sev_db.rank(path, perm)
rank = self.sev_db.rank_path(path, perm)
self.assertEqual(rank, expected_rank,
'expected rank %s, got %s' % (expected_rank, rank))
@@ -68,8 +68,7 @@ class SeverityTestCap(SeverityBaseTest):
]
def _run_test(self, params, expected):
cap_with_prefix = 'CAP_%s' % params
self._simple_severity_test(cap_with_prefix, expected)
self._capability_severity_test(params, expected)
rank = self.sev_db.rank_capability(params)
self.assertEqual(rank, expected, 'expected rank %s, got %s' % (expected, rank))