From cdf2f434ce66c2a1c21ecfceb13ac200eeaccf9c Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Mon, 3 Sep 2018 14:30:33 +0200 Subject: [PATCH] fix: Avoiding adding attributes that are already in the event --- 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 a917f6f..614b8d0 100644 --- a/misp_modules/modules/expansion/virustotal.py +++ b/misp_modules/modules/expansion/virustotal.py @@ -34,7 +34,9 @@ class VirusTotalRequest(object): 'authentihash': 'authentihash', 'ITW_urls': 'url'} def parse_request(self, q): + req_values = set() for attribute_type, attribute_value in q.items(): + req_values.add(attribute_value) try: error = self.input_types_mapping[attribute_type](attribute_value) except KeyError: @@ -42,11 +44,13 @@ class VirusTotalRequest(object): if error is not None: return error for key, values in self.results.items(): - if isinstance(key, tuple): - types, comment = key - self.to_return.append({'types': list(types), 'values': list(values), 'comment': comment}) - else: - self.to_return.append({'types': key, 'values': list(values)}) + values = values.difference(req_values) + if values: + if isinstance(key, tuple): + types, comment = key + self.to_return.append({'types': list(types), 'values': list(values), 'comment': comment}) + else: + self.to_return.append({'types': key, 'values': list(values)}) return self.to_return def get_domain(self, domain, do_not_recurse=False):