fix: Avoiding adding attributes that are already in the event

pull/222/head
chrisr3d 2018-09-03 14:30:33 +02:00
parent 33181bc52b
commit cdf2f434ce
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 9 additions and 5 deletions

View File

@ -34,7 +34,9 @@ class VirusTotalRequest(object):
'authentihash': 'authentihash', 'ITW_urls': 'url'} 'authentihash': 'authentihash', 'ITW_urls': 'url'}
def parse_request(self, q): def parse_request(self, q):
req_values = set()
for attribute_type, attribute_value in q.items(): for attribute_type, attribute_value in q.items():
req_values.add(attribute_value)
try: try:
error = self.input_types_mapping[attribute_type](attribute_value) error = self.input_types_mapping[attribute_type](attribute_value)
except KeyError: except KeyError:
@ -42,11 +44,13 @@ class VirusTotalRequest(object):
if error is not None: if error is not None:
return error return error
for key, values in self.results.items(): for key, values in self.results.items():
if isinstance(key, tuple): values = values.difference(req_values)
types, comment = key if values:
self.to_return.append({'types': list(types), 'values': list(values), 'comment': comment}) if isinstance(key, tuple):
else: types, comment = key
self.to_return.append({'types': key, 'values': list(values)}) 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 return self.to_return
def get_domain(self, domain, do_not_recurse=False): def get_domain(self, domain, do_not_recurse=False):