mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
Indent line continuations per PEP 8.
This commit is contained in:
parent
aff9bb8f81
commit
e4f88cc3a8
@ -137,10 +137,12 @@ class AAParserCachingCommon(testlib.AATestTemplate):
|
||||
with open(features_path) as f:
|
||||
features = f.read()
|
||||
if expected:
|
||||
self.assertEqual(expected_output, features,
|
||||
self.assertEqual(
|
||||
expected_output, features,
|
||||
"features contents differ, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||
else:
|
||||
self.assertNotEqual(expected_output, features,
|
||||
self.assertNotEqual(
|
||||
expected_output, features,
|
||||
"features contents equal, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||
|
||||
|
||||
|
@ -100,8 +100,7 @@ if __name__ == "__main__":
|
||||
|
||||
apparmor.easyprof.print_files(files)
|
||||
sys.exit(0)
|
||||
elif binary is None and not options.profile_name and \
|
||||
not options.manifest:
|
||||
elif binary is None and not options.profile_name and not options.manifest:
|
||||
error("Must specify binary and/or profile name\n%s" % m)
|
||||
|
||||
params = apparmor.easyprof.gen_policy_params(binary, options)
|
||||
|
@ -521,7 +521,9 @@ class AppArmorEasyProfile:
|
||||
return rule
|
||||
|
||||
|
||||
def gen_policy(self, name,
|
||||
def gen_policy(
|
||||
self,
|
||||
name,
|
||||
binary=None,
|
||||
profile_name=None,
|
||||
template_var=[],
|
||||
|
@ -80,11 +80,13 @@ class BaseRule:
|
||||
return None, True
|
||||
elif type(rulepart) is str:
|
||||
if len(rulepart.strip()) == 0:
|
||||
raise AppArmorBug('Passed empty %(partname)s to %(classname)s: %(rulepart)s' %
|
||||
{'partname': partname, 'classname': self.__class__.__name__, 'rulepart': str(rulepart)})
|
||||
raise AppArmorBug(
|
||||
'Passed empty %(partname)s to %(classname)s: %(rulepart)s'
|
||||
% {'partname': partname, 'classname': self.__class__.__name__, 'rulepart': str(rulepart)})
|
||||
return AARE(rulepart, is_path=is_path, log_event=log_event), False
|
||||
else:
|
||||
raise AppArmorBug('Passed unknown %(partname)s to %(classname)s: %(rulepart)s'
|
||||
raise AppArmorBug(
|
||||
'Passed unknown %(partname)s to %(classname)s: %(rulepart)s'
|
||||
% {'partname': partname, 'classname': self.__class__.__name__, 'rulepart': str(rulepart)})
|
||||
|
||||
def __repr__(self):
|
||||
@ -506,13 +508,15 @@ def check_and_split_list(lst, allowed_keywords, all_obj, classname, keyword_name
|
||||
elif type(lst) in (list, tuple, set) and (len(lst) > 0 or allow_empty_list):
|
||||
result_list = set(lst)
|
||||
else:
|
||||
raise AppArmorBug('Passed unknown %(type)s object to %(classname)s: %(unknown_object)s' %
|
||||
raise AppArmorBug(
|
||||
'Passed unknown %(type)s object to %(classname)s: %(unknown_object)s' %
|
||||
{'type': type(lst), 'classname': classname, 'unknown_object': str(lst)})
|
||||
|
||||
unknown_items = set()
|
||||
for item in result_list:
|
||||
if not item.strip():
|
||||
raise AppArmorBug('Passed empty %(keyword_name)s to %(classname)s' %
|
||||
raise AppArmorBug(
|
||||
'Passed empty %(keyword_name)s to %(classname)s' %
|
||||
{'keyword_name': keyword_name, 'classname': classname})
|
||||
if item not in allowed_keywords:
|
||||
unknown_items.add(item)
|
||||
|
@ -72,8 +72,8 @@ class AliasRule(BaseRule):
|
||||
orig_path = strip_quotes(matches.group('orig_path').strip())
|
||||
target = strip_quotes(matches.group('target').strip())
|
||||
|
||||
return AliasRule(orig_path, target,
|
||||
audit=False, deny=False, allow_keyword=False, comment=comment)
|
||||
return AliasRule(
|
||||
orig_path, target, audit=False, deny=False, allow_keyword=False, comment=comment)
|
||||
|
||||
def get_clean(self, depth=0):
|
||||
'''return rule (in clean/default formatting)'''
|
||||
|
@ -69,8 +69,7 @@ class IncludeRule(BaseRule):
|
||||
# TODO: move re_match_include_parse() from regex.py to this class after converting all code to use IncludeRule
|
||||
path, ifexists, ismagic = re_match_include_parse(raw_rule, cls.rule_name)
|
||||
|
||||
return cls(path, ifexists, ismagic,
|
||||
audit=False, deny=False, allow_keyword=False, comment=comment)
|
||||
return cls(path, ifexists, ismagic, audit=False, deny=False, allow_keyword=False, comment=comment)
|
||||
|
||||
def get_clean(self, depth=0):
|
||||
'''return rule (in clean/default formatting)'''
|
||||
|
@ -104,8 +104,8 @@ class PtraceRule(BaseRule):
|
||||
access = PtraceRule.ALL
|
||||
peer = PtraceRule.ALL
|
||||
|
||||
return PtraceRule(access, peer,
|
||||
audit=audit, deny=deny, allow_keyword=allow_keyword, comment=comment)
|
||||
return PtraceRule(
|
||||
access, peer, audit=audit, deny=deny, allow_keyword=allow_keyword, comment=comment)
|
||||
|
||||
def get_clean(self, depth=0):
|
||||
'''return rule (in clean/default formatting)'''
|
||||
|
@ -131,8 +131,7 @@ class RlimitRule(BaseRule):
|
||||
else:
|
||||
raise AppArmorException(_("Invalid rlimit rule '%s' - value missing") % raw_rule) # pragma: no cover - would need breaking the regex
|
||||
|
||||
return RlimitRule(rlimit, value,
|
||||
comment=comment)
|
||||
return RlimitRule(rlimit, value, comment=comment)
|
||||
|
||||
def get_clean(self, depth=0):
|
||||
'''return rule (in clean/default formatting)'''
|
||||
|
@ -101,8 +101,7 @@ def parse_args(args=None, parser=None):
|
||||
|
||||
def gen_policy_name(binary):
|
||||
'''Generate a temporary policy based on the binary name'''
|
||||
return "sandbox-%s%s" % (pwd.getpwuid(os.geteuid())[0],
|
||||
re.sub(r'/', '_', binary))
|
||||
return "sandbox-%s%s" % (pwd.getpwuid(os.geteuid())[0], re.sub(r'/', '_', binary))
|
||||
|
||||
def set_environ(env):
|
||||
keys = env.keys()
|
||||
@ -169,10 +168,7 @@ def run_sandbox(command, opt):
|
||||
return rc, report
|
||||
|
||||
class SandboxXserver():
|
||||
def __init__(self, title, geometry=None,
|
||||
driver=None,
|
||||
xauth=None,
|
||||
clipboard=False):
|
||||
def __init__(self, title, geometry=None, driver=None, xauth=None, clipboard=False):
|
||||
self.geometry = geometry
|
||||
self.title = title
|
||||
self.pids = []
|
||||
@ -673,17 +669,14 @@ def run_xsandbox(command, opt):
|
||||
|
||||
# first, start X
|
||||
if opt.xserver.lower() == "xephyr":
|
||||
x = SandboxXephyr(command[0], geometry=opt.xephyr_geometry,
|
||||
xauth=opt.xauthority)
|
||||
x = SandboxXephyr(command[0], geometry=opt.xephyr_geometry, xauth=opt.xauthority)
|
||||
elif opt.xserver.lower() == "xpra3d":
|
||||
x = SandboxXpra(command[0], geometry=None,
|
||||
driver="xdummy",
|
||||
xauth=opt.xauthority,
|
||||
x = SandboxXpra(
|
||||
command[0], geometry=None, driver="xdummy", xauth=opt.xauthority,
|
||||
clipboard=opt.with_clipboard)
|
||||
else:
|
||||
x = SandboxXpra(command[0], geometry=None,
|
||||
xauth=opt.xauthority,
|
||||
clipboard=opt.with_clipboard)
|
||||
x = SandboxXpra(
|
||||
command[0], geometry=None, xauth=opt.xauthority, clipboard=opt.with_clipboard)
|
||||
|
||||
x.verify_host_setup()
|
||||
|
||||
|
@ -144,8 +144,7 @@ class ChangeProfileFromInit(ChangeProfileTest):
|
||||
(ChangeProfileRule('unsafe', '/foo', '/bar') , exp(False, False, False, '' , 'unsafe', '/foo', False, '/bar' , False)),
|
||||
(ChangeProfileRule(None , '/foo', ChangeProfileRule.ALL) , exp(False, False, False, '' , None , '/foo', False, None , True )),
|
||||
(ChangeProfileRule(None , ChangeProfileRule.ALL, '/bar') , exp(False, False, False, '' , None , None , True , '/bar' , False)),
|
||||
(ChangeProfileRule(None , ChangeProfileRule.ALL,
|
||||
ChangeProfileRule.ALL) , exp(False, False, False, '' , None, None , True , None , True )),
|
||||
(ChangeProfileRule(None , ChangeProfileRule.ALL, ChangeProfileRule.ALL), exp(False, False, False, '' , None, None , True , None , True )),
|
||||
)
|
||||
|
||||
def _run_test(self, obj, expected):
|
||||
|
@ -269,8 +269,7 @@ class AARegexSignal(AARegexTest):
|
||||
(' signal (send, receive),', (None, None, 'signal (send, receive),', '(send, receive)', None)),
|
||||
(' audit signal (receive),', ('audit', None, 'signal (receive),', '(receive)', None)),
|
||||
(' signal (send, receive) set=(usr1 usr2),', (None, None, 'signal (send, receive) set=(usr1 usr2),', '(send, receive) set=(usr1 usr2)', None)),
|
||||
(' signal send set=(hup, quit) peer=/usr/sbin/daemon,', (None, None, 'signal send set=(hup, quit) peer=/usr/sbin/daemon,',
|
||||
'send set=(hup, quit) peer=/usr/sbin/daemon', None)),
|
||||
(' signal send set=(hup, quit) peer=/usr/sbin/daemon,', (None, None, 'signal send set=(hup, quit) peer=/usr/sbin/daemon,', 'send set=(hup, quit) peer=/usr/sbin/daemon', None)),
|
||||
|
||||
(' signalling,', False),
|
||||
(' audit signalling,', False),
|
||||
|
Loading…
x
Reference in New Issue
Block a user