in modular_api/services/audit_service.py [0:0]
def filter_audit(self, group=None, from_date=None, to_date=None,
command=None, limit=None) -> tuple:
"""
Returns audit events by provided filters
"""
_LOG.info(f'Going to filter audit by the following parameters: group: '
f'{group}, command: {command}, from_date: {from_date}, '
f'to_date: {to_date}, limit: {limit}')
audit_list = []
invalid_list = []
audit = self.get_audit(group=group, command=command,
from_date=from_date,
to_date=to_date, limit=limit)
for event in audit:
valid_event = AuditService.check_audit_hash(event)
pretty_value = {
'Group': event.group,
'Command': event.command,
'Timestamp': convert_datetime_to_human_readable(event.timestamp),
'Parameters': event.parameters,
'Execution warnings': event.warnings,
'Result': event.result,
'Consistency status': 'Compromised' if not valid_event else 'OK'
}
if not valid_event:
invalid_list.append(pretty_value)
audit_list.append(pretty_value)
return audit_list, invalid_list