From 936e30b15b97643828b95011bbf7e349acd9f146 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Mon, 3 Sep 2018 12:03:42 +0200 Subject: [PATCH] fix: Multiple attributes parsing support - Fixing one of my previous changes not processing multiple attributes parsing --- misp_modules/modules/expansion/virustotal.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/misp_modules/modules/expansion/virustotal.py b/misp_modules/modules/expansion/virustotal.py index de91e09..4ebbd43 100644 --- a/misp_modules/modules/expansion/virustotal.py +++ b/misp_modules/modules/expansion/virustotal.py @@ -33,10 +33,14 @@ class VirusTotalRequest(object): self.output_types_mapping = {'submission_names': 'filename', 'ssdeep': 'ssdeep', 'authentihash': 'authentihash', 'ITW_urls': 'url'} - def parse_request(self, attribute_type, attribute_value): - error = self.input_types_mapping[attribute_type](attribute_value) - if error is not None: - return error + def parse_request(self, q): + for attribute_type, attribute_value in q.items(): + try: + error = self.input_types_mapping[attribute_type](attribute_value) + except KeyError: + continue + if error is not None: + return error for key, values in self.results.items(): if isinstance(key, tuple): types, comment = key @@ -144,7 +148,7 @@ def handler(q=False): return misperrors del q['module'] query = VirusTotalRequest(q.pop('config')) - r = query.parse_request(*list(q.items())[0]) + r = query.parse_request(q) if isinstance(r, str): misperrors['error'] = r return misperrors