fix: Multiple attributes parsing support

- Fixing one of my previous changes not processing
  multiple attributes parsing
pull/222/head
chrisr3d 2018-09-03 12:03:42 +02:00
parent 2af947a2de
commit 936e30b15b
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 9 additions and 5 deletions

View File

@ -33,8 +33,12 @@ class VirusTotalRequest(object):
self.output_types_mapping = {'submission_names': 'filename', 'ssdeep': 'ssdeep', self.output_types_mapping = {'submission_names': 'filename', 'ssdeep': 'ssdeep',
'authentihash': 'authentihash', 'ITW_urls': 'url'} 'authentihash': 'authentihash', 'ITW_urls': 'url'}
def parse_request(self, attribute_type, attribute_value): def parse_request(self, q):
for attribute_type, attribute_value in q.items():
try:
error = self.input_types_mapping[attribute_type](attribute_value) error = self.input_types_mapping[attribute_type](attribute_value)
except KeyError:
continue
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():
@ -144,7 +148,7 @@ def handler(q=False):
return misperrors return misperrors
del q['module'] del q['module']
query = VirusTotalRequest(q.pop('config')) query = VirusTotalRequest(q.pop('config'))
r = query.parse_request(*list(q.items())[0]) r = query.parse_request(q)
if isinstance(r, str): if isinstance(r, str):
misperrors['error'] = r misperrors['error'] = r
return misperrors return misperrors