Skip to content

Commit 69e793a

Browse files
committed
chg: [vulnerability_parser] Supporting GCVE vulnerability IDs
- Including CIRCL and AHA sources - Take on me (Take on me) Take me on (Take on me) I'll be gone In a day or two
1 parent 4c50f51 commit 69e793a

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

misp_modules/modules/expansion/_vulnerability_parser/vulnerability_parser.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ class VulnerabilityLookupMapping(VulnerabilityMapping):
127127
'lastModified': 'modified',
128128
'published': 'published'
129129
}
130+
__gcve_mapping = {
131+
"vulnId": "id",
132+
"datePublished": "published",
133+
"dateUpdated": "modified",
134+
"state": "state"
135+
}
130136
__gsd_mapping = {"id": "id", "details": "description", "modified": "modified"}
131137
__jvn_mapping = {
132138
"sec:identifier": "id",
@@ -154,6 +160,7 @@ class VulnerabilityLookupMapping(VulnerabilityMapping):
154160
"cnvd": "_parse_cnvd_description",
155161
"cve": "_parse_cve_description",
156162
'fkie_cve': '_parse_fkie_description',
163+
"gcve": "_parse_gcve_description",
157164
"ghsa": "_parse_standard_description",
158165
"gsd": "_parse_gsd_description",
159166
"jvndb": "_parse_jvn_description",
@@ -209,6 +216,10 @@ def cwe_mapping(cls) -> dict:
209216
def fkie_mapping(cls) -> dict:
210217
return cls.__fkie_mapping
211218

219+
@classmethod
220+
def gcve_mapping(cls) -> dict:
221+
return cls.__gcve_mapping
222+
212223
@classmethod
213224
def gsd_mapping(cls) -> dict:
214225
return cls.__gsd_mapping
@@ -462,6 +473,54 @@ def _parse_fkie_description(self, lookup_result: dict) -> str:
462473
attribute.uuid, 'weakened-by'
463474
)
464475

476+
def _parse_gcve_description(self, lookup_result: dict) -> str:
477+
metadata = lookup_result['cveMetadata']
478+
misp_object = self._create_vulnerability_object(metadata['vulnId'])
479+
for field, relation in self.mapping.gcve_mapping().items():
480+
misp_object.add_attribute(relation, metadata[field])
481+
vulnerability_object = self.misp_event.add_object(misp_object)
482+
container = lookup_result['containers'].get('cna')
483+
if container is not None:
484+
if container.get('title'):
485+
vulnerability_object.add_attribute(
486+
'summary', container['title']
487+
)
488+
for description in container.get('descriptions', []):
489+
vulnerability_object.add_attribute(
490+
'description', description['value']
491+
)
492+
for reference in container.get('references', []):
493+
vulnerability_object.add_attribute(
494+
'references', reference['url']
495+
)
496+
for metric in container.get('metrics', []):
497+
for key, fields in metric.items():
498+
if key.startswith('cvssV'):
499+
vulnerability_object.add_attribute(
500+
'cvss-score', fields['baseScore']
501+
)
502+
vulnerability_object.add_attribute(
503+
'cvss-string', fields['vectorString']
504+
)
505+
for credit in container.get('credits', []):
506+
vulnerability_object.add_attribute('credit', credit['value'])
507+
for weakness in container.get('problemTypes', []):
508+
for description in weakness.get('descriptions', []):
509+
weakness_object = MISPObject('weakness')
510+
weakness_object.add_attribute('id', description['cweId'])
511+
weakness_object.add_attribute(
512+
'description', description['description']
513+
)
514+
vulnerability_object.add_reference(
515+
self.misp_event.add_object(weakness_object).uuid,
516+
'weakened-by'
517+
)
518+
if metadata.get('cveId') is not None:
519+
vulnerability_object.add_reference(
520+
self._parse_alias(metadata['cveId']), 'related-to'
521+
)
522+
return vulnerability_object.uuid
523+
465524
def _parse_gsd_description(self, lookup_result: dict) -> str:
466525
gsd_details = lookup_result["gsd"]["osvSchema"]
467526
misp_object = self._create_vulnerability_object(gsd_details['id'])

0 commit comments

Comments
 (0)