@@ -20,6 +20,7 @@ class VEXParse:
20
20
- vextype (str): The type of VEX file.
21
21
- logger: The logger object for logging messages.
22
22
- parsed_data: A dictionary to store the parsed data.
23
+ - serialNumbers: serialNumbers from the bom_link used to check linkage with sbom.
23
24
24
25
Methods:
25
26
- __init__(self, filename: str, vextype: str, logger=None): Initializes the VEXParse object.
@@ -60,11 +61,16 @@ def __init__(self, filename: str, vextype: str, logger=None):
60
61
self .vextype = vextype
61
62
self .logger = logger or LOGGER .getChild (self .__class__ .__name__ )
62
63
self .parsed_data = {}
64
+ self .serialNumbers = set ()
63
65
64
66
def parse_vex (self ) -> DefaultDict [ProductInfo , TriageData ]:
65
67
"""Parses the VEX file and extracts the necessary fields from the vulnerabilities."""
66
68
vexparse = VEXParser (vex_type = self .vextype )
67
69
vexparse .parse (self .filename )
70
+ if self .vextype == "auto" :
71
+ self .vextype = vexparse .get_type ()
72
+
73
+ self .logger .info (f"Parsed Vex File: { self .filename } of type: { self .vextype } " )
68
74
self .logger .debug (f"VEX Vulnerabilities: { vexparse .get_vulnerabilities ()} " )
69
75
self .__process_vulnerabilities (vexparse .get_vulnerabilities ())
70
76
self .__process_metadata (vexparse .get_metadata ())
@@ -101,7 +107,6 @@ def __process_product(self, product) -> None:
101
107
102
108
def __process_vulnerabilities (self , vulnerabilities ) -> None :
103
109
""" "processes the vulnerabilities and extracts the necessary fields from the vulnerability."""
104
- # for now cyclonedx is supported with minor tweaks other will be supported later
105
110
for vuln in vulnerabilities :
106
111
# Extract necessary fields from the vulnerability
107
112
cve_id = vuln .get ("id" )
@@ -110,10 +115,18 @@ def __process_vulnerabilities(self, vulnerabilities) -> None:
110
115
response = vuln .get ("remediation" )
111
116
comments = vuln .get ("comments" )
112
117
severity = vuln .get ("severity" ) # Severity is not available in Lib4VEX
113
- # Decode the bom reference for cyclonedx something similar would be done for other formats
118
+ # Decode the bom reference for cyclonedx and purl for csaf and openvex
114
119
product_info = None
120
+ serialNumber = ""
115
121
if self .vextype == "cyclonedx" :
116
- product_info = decode_bom_ref (vuln .get ("bom_link" ))
122
+ decoded_ref = decode_bom_ref (vuln .get ("bom_link" ))
123
+ if isinstance (decoded_ref , tuple ) and not isinstance (
124
+ decoded_ref , ProductInfo
125
+ ):
126
+ product_info , serialNumber = decoded_ref
127
+ self .serialNumbers .add (serialNumber )
128
+ else :
129
+ product_info = decoded_ref
117
130
elif self .vextype in ["openvex" , "csaf" ]:
118
131
product_info = decode_purl (vuln .get ("purl" ))
119
132
if product_info :
0 commit comments