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

Simplify rule._logprof_header_localvars() implementations

This commit is contained in:
Mark Grassi
2022-11-19 22:13:36 -05:00
parent b150c40ed1
commit db99138f56
12 changed files with 35 additions and 53 deletions

View File

@@ -50,7 +50,7 @@ class AbiRule(IncludeRule):
return ('%s%s "%s",%s' % (space, self.rule_name, self.path, self.comment))
def _logprof_header_localvars(self):
return [_('Abi'), self.get_clean()]
return _('Abi'), self.get_clean()
class AbiRuleset(IncludeRuleset):

View File

@@ -92,11 +92,7 @@ class AliasRule(BaseRule):
return True
def _logprof_header_localvars(self):
headers = []
return headers + [
_('Alias'), '%s -> %s' % (self.orig_path, self.target),
]
return _('Alias'), '%s -> %s' % (self.orig_path, self.target)
class AliasRuleset(BaseRuleset):

View File

@@ -99,11 +99,7 @@ class BooleanRule(BaseRule):
return True
def _logprof_header_localvars(self):
headers = []
return headers + [
_('Boolean Variable'), self.get_clean(),
]
return _('Boolean Variable'), self.get_clean()
class BooleanRuleset(BaseRuleset):

View File

@@ -125,9 +125,7 @@ class CapabilityRule(BaseRule):
def _logprof_header_localvars(self):
cap_txt = logprof_value_or_all(self.capability, self.all_caps)
return [
_('Capability'), cap_txt,
]
return _('Capability'), cap_txt
class CapabilityRuleset(BaseRuleset):

View File

@@ -288,25 +288,25 @@ class DbusRule(BaseRule):
return True
def _logprof_header_localvars(self):
access = logprof_value_or_all(self.access, self.all_access)
bus = logprof_value_or_all(self.bus, self.all_buses)
path = logprof_value_or_all(self.path, self.all_paths)
name = logprof_value_or_all(self.name, self.all_names)
interface = logprof_value_or_all(self.interface, self.all_interfaces)
member = logprof_value_or_all(self.member, self.all_members)
peername = logprof_value_or_all(self.peername, self.all_peernames)
peerlabel = logprof_value_or_all(self.peerlabel, self.all_peerlabels)
access = logprof_value_or_all(self.access, self.all_access) # noqa: E221
bus = logprof_value_or_all(self.bus, self.all_buses) # noqa: E221
path = logprof_value_or_all(self.path, self.all_paths) # noqa: E221
name = logprof_value_or_all(self.name, self.all_names) # noqa: E221
interface = logprof_value_or_all(self.interface, self.all_interfaces)
member = logprof_value_or_all(self.member, self.all_members) # noqa: E221
peername = logprof_value_or_all(self.peername, self.all_peernames) # noqa: E221
peerlabel = logprof_value_or_all(self.peerlabel, self.all_peerlabels)
return [
_('Access mode'), access,
_('Bus'), bus,
_('Path'), path,
_('Name'), name,
_('Interface'), interface,
_('Member'), member,
_('Peer name'), peername,
_('Peer label'), peerlabel,
]
return (
_('Access mode'), access,
_('Bus'), bus,
_('Path'), path,
_('Name'), name,
_('Interface'), interface,
_('Member'), member,
_('Peer name'), peername,
_('Peer label'), peerlabel,
)
class DbusRuleset(BaseRuleset):

View File

@@ -108,7 +108,7 @@ class IncludeRule(BaseRule):
return True
def _logprof_header_localvars(self):
return [_('Include'), self.get_clean()]
return _('Include'), self.get_clean()
def get_full_paths(self, profile_dir):
"""get list of full paths of an include (can contain multiple paths if self.path is a directory)"""

View File

@@ -169,10 +169,10 @@ class NetworkRule(BaseRule):
family = logprof_value_or_all(self.domain, self.all_domains) # noqa: E221
sock_type = logprof_value_or_all(self.type_or_protocol, self.all_type_or_protocols)
return [
return (
_('Network Family'), family,
_('Socket Type'), sock_type,
]
)
class NetworkRuleset(BaseRuleset):

View File

@@ -151,10 +151,10 @@ class PtraceRule(BaseRule):
access = logprof_value_or_all(self.access, self.all_access)
peer = logprof_value_or_all(self.peer, self.all_peers) # noqa: E221
return [
return (
_('Access mode'), access,
_('Peer'), peer,
]
)
class PtraceRuleset(BaseRuleset):

View File

@@ -220,17 +220,15 @@ class RlimitRule(BaseRule):
return True
def _logprof_header_localvars(self):
rlimit_txt = self.rlimit
if self.all_values:
values_txt = 'infinity'
else:
values_txt = self.value
return [
_('Rlimit'), rlimit_txt,
return (
_('Rlimit'), self.rlimit,
_('Value'), values_txt,
]
)
class RlimitRuleset(BaseRuleset):

View File

@@ -211,11 +211,11 @@ class SignalRule(BaseRule):
signal = logprof_value_or_all(self.signal, self.all_signals)
peer = logprof_value_or_all(self.peer, self.all_peers) # noqa: E221
return [
return (
_('Access mode'), access,
_('Signal'), signal,
_('Peer'), peer
]
_('Peer'), peer,
)
class SignalRuleset(BaseRuleset):

View File

@@ -112,9 +112,7 @@ class UserNamespaceRule(BaseRule):
def _logprof_header_localvars(self):
access = logprof_value_or_all(self.access, self.all_access)
return (
_('Access mode'), access,
)
return _('Access mode'), access
class UserNamespaceRuleset(BaseRuleset):

View File

@@ -118,11 +118,7 @@ class VariableRule(BaseRule):
return True
def _logprof_header_localvars(self):
headers = []
return headers + [
_('Variable'), self.get_clean(),
]
return _('Variable'), self.get_clean()
class VariableRuleset(BaseRuleset):