From 458b10e2ea29b49f973f66b658e874ad7715610c Mon Sep 17 00:00:00 2001 From: abdullah Date: Fri, 16 Oct 2020 11:29:02 -0400 Subject: [PATCH] initial cdr output --- metadefender.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/metadefender.py b/metadefender.py index 772af4a..98b2108 100644 --- a/metadefender.py +++ b/metadefender.py @@ -299,7 +299,7 @@ def parse_results(self, response: Dict[str, Any]): res = Result() scan_results = response.get('scan_results', response) virus_name = "" - + process_results = response.get('process_info', response) if scan_results is not None and scan_results.get('progress_percentage') == 100: hit = False fail = False @@ -363,5 +363,21 @@ def parse_results(self, response: Dict[str, Any]): # Add the queue time to a list, which will be later used to calculate average queue time self.nodes[self.current_node]['queue_times'].append(queue_time) self.nodes[self.current_node]['file_count'] += 1 + if process_results is not None and process_results.get('progress_percentage') == 100: + hit = False + fail = False + cdr_fails = ResultSection('CDR Failed or No Malicious Files Found') + processed = process_results.get('post_processing', process_results) + if processed['actions_failed']: + fail = True + elif processed['actions_ran']: + hit=True + #add cdr json extracted + if hit: + cdr_json_section = ResultSection('CDR Succesfully Executed', body_format=BODY_FORMAT.JSON, + body=json.dumps(processed)) + res.add_section(cdr_json_section) + if fail: + res.add_section(cdr_fails) return res