mirror of https://github.com/MISP/misp-modules
fix: [vulnerability_lookup] Avoiding KeyError exceptions on some fields
parent
42fb1bcf14
commit
7d7dc1e633
|
@ -152,7 +152,7 @@ class VulnerabilityLookupParser(VulnerabilityParser):
|
||||||
for field, relation in self.mapping.csaf_mapping().items():
|
for field, relation in self.mapping.csaf_mapping().items():
|
||||||
misp_object.add_attribute(relation, tracking[field])
|
misp_object.add_attribute(relation, tracking[field])
|
||||||
misp_object.add_attribute('summary', description['title'])
|
misp_object.add_attribute('summary', description['title'])
|
||||||
for reference in description['references']:
|
for reference in description.get('references', []):
|
||||||
misp_object.add_attribute('references', reference['url'])
|
misp_object.add_attribute('references', reference['url'])
|
||||||
misp_object.add_attribute('credit', description['publisher']['name'])
|
misp_object.add_attribute('credit', description['publisher']['name'])
|
||||||
misp_object.add_reference(self.misp_attribute.uuid, 'describes')
|
misp_object.add_reference(self.misp_attribute.uuid, 'describes')
|
||||||
|
@ -183,7 +183,7 @@ class VulnerabilityLookupParser(VulnerabilityParser):
|
||||||
|
|
||||||
def _parse_cve_description(self, lookup_result: dict) -> str:
|
def _parse_cve_description(self, lookup_result: dict) -> str:
|
||||||
misp_object = MISPObject('vulnerability')
|
misp_object = MISPObject('vulnerability')
|
||||||
cveMetaData = lookup_result['cveMetaData']
|
cveMetaData = lookup_result['cveMetadata']
|
||||||
for field, relation in self.mapping.cve_mapping().items():
|
for field, relation in self.mapping.cve_mapping().items():
|
||||||
misp_object.add_attribute(relation, cveMetaData[field])
|
misp_object.add_attribute(relation, cveMetaData[field])
|
||||||
for reference in lookup_result['containers']['cna']['references']:
|
for reference in lookup_result['containers']['cna']['references']:
|
||||||
|
@ -267,9 +267,8 @@ class VulnerabilityLookupParser(VulnerabilityParser):
|
||||||
misp_object = MISPObject('vulnerability')
|
misp_object = MISPObject('vulnerability')
|
||||||
for field, relation in self.mapping.standard_mapping().items():
|
for field, relation in self.mapping.standard_mapping().items():
|
||||||
misp_object.add_attribute(relation, lookup_result[field])
|
misp_object.add_attribute(relation, lookup_result[field])
|
||||||
misp_object.add_attribute(
|
for cvss in lookup_result.get('severity', []):
|
||||||
'cvss-string', lookup_result['severity']['score']
|
misp_object.add_attribute('cvss-string', cvss['score'])
|
||||||
)
|
|
||||||
for reference in lookup_result['references']:
|
for reference in lookup_result['references']:
|
||||||
misp_object.add_attribute('references', reference['url'])
|
misp_object.add_attribute('references', reference['url'])
|
||||||
misp_object.add_reference(self.misp_attribute.uuid, 'related-to')
|
misp_object.add_reference(self.misp_attribute.uuid, 'related-to')
|
||||||
|
|
Loading…
Reference in New Issue