2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 05:17:59 +00:00

Change read_log to return only hashlog

self.log is unused, drop it.

Also change all places that call read_log() to match the simplified
return value.
This commit is contained in:
Christian Boltz 2019-05-04 00:09:51 +02:00
parent d4512aa5d7
commit 9a92909a89
No known key found for this signature in database
GPG Key ID: C6A682EA63C82F1C
3 changed files with 5 additions and 11 deletions

View File

@ -1709,7 +1709,7 @@ def do_logprof_pass(logmark='', passno=0, log_pid=log_pid):
## UI_ask_to_enable_repo()
log_reader = apparmor.logparser.ReadLog(log_pid, logfile, active_profiles, profile_dir)
(log, hashlog) = log_reader.read_log(logmark)
hashlog = log_reader.read_log(logmark)
handle_hashlog(hashlog)
ask_exec(hashlog)
@ -1717,8 +1717,6 @@ def do_logprof_pass(logmark='', passno=0, log_pid=log_pid):
#read_log(logmark)
#print(log)
log_dict = collapse_log()
ask_the_questions(log_dict)

View File

@ -46,7 +46,6 @@ class ReadLog:
self.profile_dir = profile_dir
self.pid = pid # XXX unused
self.active_profiles = active_profiles
self.log = [] # XXX unused
self.hashlog = { 'PERMITTING': {}, 'REJECTING': {}, 'AUDIT': {} } # structure inside {}: {'profilename': init_hashlog(aamode, profilename), 'profilename2': init_hashlog(...), ...}
self.debug_logger = DebugLogger('ReadLog')
self.LOG = None
@ -306,7 +305,7 @@ class ReadLog:
self.LOG.close()
self.logmark = ''
return (self.log, self.hashlog)
return self.hashlog
# operation types that can be network or file operations
# (used by op_type() which checks some event details to decide)

View File

@ -238,7 +238,7 @@ def logfile_to_profile(logfile):
apparmor.aa.active_profiles.add(profile_dummy_file, profile, '')
log_reader = ReadLog(dict(), logfile, apparmor.aa.active_profiles, '')
(log, hashlog) = log_reader.read_log('')
hashlog = log_reader.read_log('')
apparmor.aa.handle_hashlog(hashlog)
apparmor.aa.ask_exec(hashlog)
@ -261,9 +261,6 @@ def logfile_to_profile(logfile):
log_is_empty = True
if log != []:
log_is_empty = False
for tmpaamode in hashlog:
for tmpprofile in hashlog[tmpaamode]:
for tmpruletype in hashlog[tmpaamode][tmpprofile]:
@ -273,10 +270,10 @@ def logfile_to_profile(logfile):
if logfile.split('/')[-1][:-3] in log_to_profile_known_empty_log:
# unfortunately this function might be called outside Unittest.TestCase, therefore we can't use assertEqual / assertNotEqual
if log_is_empty == False:
raise Exception('got non-empty log for logfile in log_to_profile_known_empty_log: %s %s' % (logfile, log))
raise Exception('got non-empty log for logfile in log_to_profile_known_empty_log: %s %s' % (logfile, hashlog))
else:
if log_is_empty == True:
raise Exception('got empty log for logfile not in log_to_profile_known_empty_log: %s %s' % (logfile, log))
raise Exception('got empty log for logfile not in log_to_profile_known_empty_log: %s %s' % (logfile, hashlog))
new_profile = apparmor.aa.serialize_profile(log_dict[aamode][profile], profile, {})