mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-01 23:05:11 +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:
@@ -1709,7 +1709,7 @@ def do_logprof_pass(logmark='', passno=0, log_pid=log_pid):
|
|||||||
## UI_ask_to_enable_repo()
|
## UI_ask_to_enable_repo()
|
||||||
|
|
||||||
log_reader = apparmor.logparser.ReadLog(log_pid, logfile, active_profiles, profile_dir)
|
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)
|
handle_hashlog(hashlog)
|
||||||
ask_exec(hashlog)
|
ask_exec(hashlog)
|
||||||
@@ -1717,8 +1717,6 @@ def do_logprof_pass(logmark='', passno=0, log_pid=log_pid):
|
|||||||
|
|
||||||
#read_log(logmark)
|
#read_log(logmark)
|
||||||
|
|
||||||
#print(log)
|
|
||||||
|
|
||||||
log_dict = collapse_log()
|
log_dict = collapse_log()
|
||||||
|
|
||||||
ask_the_questions(log_dict)
|
ask_the_questions(log_dict)
|
||||||
|
@@ -46,7 +46,6 @@ class ReadLog:
|
|||||||
self.profile_dir = profile_dir
|
self.profile_dir = profile_dir
|
||||||
self.pid = pid # XXX unused
|
self.pid = pid # XXX unused
|
||||||
self.active_profiles = active_profiles
|
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.hashlog = { 'PERMITTING': {}, 'REJECTING': {}, 'AUDIT': {} } # structure inside {}: {'profilename': init_hashlog(aamode, profilename), 'profilename2': init_hashlog(...), ...}
|
||||||
self.debug_logger = DebugLogger('ReadLog')
|
self.debug_logger = DebugLogger('ReadLog')
|
||||||
self.LOG = None
|
self.LOG = None
|
||||||
@@ -306,7 +305,7 @@ class ReadLog:
|
|||||||
self.LOG.close()
|
self.LOG.close()
|
||||||
self.logmark = ''
|
self.logmark = ''
|
||||||
|
|
||||||
return (self.log, self.hashlog)
|
return self.hashlog
|
||||||
|
|
||||||
# operation types that can be network or file operations
|
# operation types that can be network or file operations
|
||||||
# (used by op_type() which checks some event details to decide)
|
# (used by op_type() which checks some event details to decide)
|
||||||
|
@@ -238,7 +238,7 @@ def logfile_to_profile(logfile):
|
|||||||
apparmor.aa.active_profiles.add(profile_dummy_file, profile, '')
|
apparmor.aa.active_profiles.add(profile_dummy_file, profile, '')
|
||||||
|
|
||||||
log_reader = ReadLog(dict(), logfile, apparmor.aa.active_profiles, '')
|
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.handle_hashlog(hashlog)
|
||||||
apparmor.aa.ask_exec(hashlog)
|
apparmor.aa.ask_exec(hashlog)
|
||||||
@@ -261,9 +261,6 @@ def logfile_to_profile(logfile):
|
|||||||
|
|
||||||
log_is_empty = True
|
log_is_empty = True
|
||||||
|
|
||||||
if log != []:
|
|
||||||
log_is_empty = False
|
|
||||||
|
|
||||||
for tmpaamode in hashlog:
|
for tmpaamode in hashlog:
|
||||||
for tmpprofile in hashlog[tmpaamode]:
|
for tmpprofile in hashlog[tmpaamode]:
|
||||||
for tmpruletype in hashlog[tmpaamode][tmpprofile]:
|
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:
|
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
|
# unfortunately this function might be called outside Unittest.TestCase, therefore we can't use assertEqual / assertNotEqual
|
||||||
if log_is_empty == False:
|
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:
|
else:
|
||||||
if log_is_empty == True:
|
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, {})
|
new_profile = apparmor.aa.serialize_profile(log_dict[aamode][profile], profile, {})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user