mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 22:05:27 +00:00
severity.py: change rank_capability() to not expect the CAP_ prefix
Change rank_capability() so that it doesn't expect the CAP_ prefix. This makes usage easier because callers can simply hand over the capability name. Also change rank() to call rank_capability() without the CAP_ prefix. Acked-by: Steve Beattie <steve@nxnw.org>
This commit is contained in:
@@ -77,7 +77,7 @@ class Severity(object):
|
||||
|
||||
def rank_capability(self, resource):
|
||||
"""Returns the severity of for the capability resource, default value if no match"""
|
||||
cap = resource.upper()
|
||||
cap = 'CAP_%s' % resource.upper()
|
||||
if cap in self.severity['CAPABILITIES'].keys():
|
||||
return self.severity['CAPABILITIES'][cap]
|
||||
# raise ValueError("unexpected capability rank input: %s"%resource)
|
||||
@@ -136,7 +136,7 @@ class Severity(object):
|
||||
elif resource[0] == '/': # file resource
|
||||
return self.handle_file(resource, mode)
|
||||
elif resource[0:4] == 'CAP_': # capability resource
|
||||
return self.rank_capability(resource)
|
||||
return self.rank_capability(resource[4:])
|
||||
else:
|
||||
raise AppArmorException("Unexpected rank input: %s" % resource)
|
||||
|
||||
|
Reference in New Issue
Block a user