mirror of https://github.com/MISP/misp-modules
fix: [variodbs] Properly handling the exploit results when there is more that 10 results
- We keep querying the VARIoT db API with the link of the next content until there is no next resultpull/590/head
parent
b964b5e2a6
commit
38a6dc810e
|
@ -73,7 +73,7 @@ class VariotdbsParser:
|
||||||
return {'results': results}
|
return {'results': results}
|
||||||
|
|
||||||
def parse_exploit_information(self, query_results):
|
def parse_exploit_information(self, query_results):
|
||||||
for exploit in query_results['results']:
|
for exploit in query_results:
|
||||||
exploit_object = MISPObject('exploit')
|
exploit_object = MISPObject('exploit')
|
||||||
exploit_object.add_attribute('exploitdb-id', exploit['edb_id'])
|
exploit_object.add_attribute('exploitdb-id', exploit['edb_id'])
|
||||||
for feature, relation in self.exploit_mapping.items():
|
for feature, relation in self.exploit_mapping.items():
|
||||||
|
@ -187,8 +187,17 @@ def handler(q=False):
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
exploit_results = r.json()
|
exploit_results = r.json()
|
||||||
if exploit_results:
|
if exploit_results:
|
||||||
parser.parse_exploit_information(exploit_results)
|
parser.parse_exploit_information(exploit_results['results'])
|
||||||
empty = False
|
empty = False
|
||||||
|
if exploit_results['next'] is not None:
|
||||||
|
while(1):
|
||||||
|
exploit_results = requests.get(exploit_results['next'], headers=headers)
|
||||||
|
if exploit_results.status_code != 200:
|
||||||
|
break
|
||||||
|
exploit_results = exploit_results.json()
|
||||||
|
parser.parse_exploit_information(exploit_results['results'])
|
||||||
|
if exploit_results['next'] is None:
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
return {'error': 'Error while querying the variotdbs API.'}
|
return {'error': 'Error while querying the variotdbs API.'}
|
||||||
if empty:
|
if empty:
|
||||||
|
|
Loading…
Reference in New Issue