mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-28 21:07:56 +00:00
Split off serialize_parse_profile_start_line() from
serialize_profile_from_old_profile() in aa.py, as a preparation to add tests and then switch to the upcoming RE_PROFILE_START wrapper function. Besides moving the code, I replaced write_prof_data[profile][hat]['profile'] and write_prof_data[profile][hat]['external'] with function parameters to avoid that I have to pass around the full write_prof_data. Note: The "lineno" parameter is technically superfluous - I kept it to have the parameters as close to parse_profile_start() as possible and hope that I can merge those functions later (when we have test coverage). Acked-by: Steve Beattie <steve@nxnw.org> for trunk and 2.9.
This commit is contained in:
parent
5b92ef4b10
commit
0636dea5c6
@ -3715,6 +3715,35 @@ def serialize_profile(profile_data, name, options):
|
|||||||
|
|
||||||
return string + '\n'
|
return string + '\n'
|
||||||
|
|
||||||
|
def serialize_parse_profile_start(line, file, lineno, profile, hat, prof_data_profile, prof_data_external, correct):
|
||||||
|
matches = RE_PROFILE_START.search(line).groups()
|
||||||
|
if profile and profile == hat and matches[3]:
|
||||||
|
hat = matches[3]
|
||||||
|
in_contained_hat = True
|
||||||
|
if prof_data_profile:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if matches[1]:
|
||||||
|
profile = matches[1]
|
||||||
|
else:
|
||||||
|
profile = matches[3]
|
||||||
|
if len(profile.split('//')) >= 2:
|
||||||
|
profile, hat = profile.split('//')[:2]
|
||||||
|
else:
|
||||||
|
hat = None
|
||||||
|
in_contained_hat = False
|
||||||
|
if hat and not prof_data_external:
|
||||||
|
correct = False
|
||||||
|
else:
|
||||||
|
hat = profile
|
||||||
|
|
||||||
|
flags = matches[6]
|
||||||
|
profile = strip_quotes(profile)
|
||||||
|
if hat:
|
||||||
|
hat = strip_quotes(hat)
|
||||||
|
|
||||||
|
return (profile, hat, flags, in_contained_hat, correct)
|
||||||
|
|
||||||
def serialize_profile_from_old_profile(profile_data, name, options):
|
def serialize_profile_from_old_profile(profile_data, name, options):
|
||||||
data = []
|
data = []
|
||||||
string = ''
|
string = ''
|
||||||
@ -3821,31 +3850,9 @@ def serialize_profile_from_old_profile(profile_data, name, options):
|
|||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
#data.append(' ')#data.append('read: '+line)
|
#data.append(' ')#data.append('read: '+line)
|
||||||
if RE_PROFILE_START.search(line):
|
if RE_PROFILE_START.search(line):
|
||||||
matches = RE_PROFILE_START.search(line).groups()
|
|
||||||
if profile and profile == hat and matches[3]:
|
|
||||||
hat = matches[3]
|
|
||||||
in_contained_hat = True
|
|
||||||
if write_prof_data[profile][hat]['profile']:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if matches[1]:
|
|
||||||
profile = matches[1]
|
|
||||||
else:
|
|
||||||
profile = matches[3]
|
|
||||||
if len(profile.split('//')) >= 2:
|
|
||||||
profile, hat = profile.split('//')[:2]
|
|
||||||
else:
|
|
||||||
hat = None
|
|
||||||
in_contained_hat = False
|
|
||||||
if hat and not write_prof_data[profile][hat]['external']:
|
|
||||||
correct = False
|
|
||||||
else:
|
|
||||||
hat = profile
|
|
||||||
|
|
||||||
flags = matches[6]
|
(profile, hat, flags, in_contained_hat, correct) = serialize_parse_profile_start(
|
||||||
profile = strip_quotes(profile)
|
line, prof_filename, None, profile, hat, write_prof_data[profile][hat]['profile'], write_prof_data[profile][hat]['external'], correct)
|
||||||
if hat:
|
|
||||||
hat = strip_quotes(hat)
|
|
||||||
|
|
||||||
if not write_prof_data[hat]['name'] == profile:
|
if not write_prof_data[hat]['name'] == profile:
|
||||||
correct = False
|
correct = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user