@@ -214,21 +214,18 @@ def get_vendor(self, product: str) -> list:
214
214
215
215
def is_valid_string (self , string_type : str , ref_string : str ) -> bool :
216
216
"""
217
- Validate the PURL, CPE string is the correct form.
217
+ Validate the CPE string is the correct form.
218
218
219
219
Args:
220
- - ref_string (str): PURL, CPE strings
221
- - string_type (str): ref_string type. (purl, cpe22 or cpe23)
220
+ - ref_string (str): CPE strings
221
+ - string_type (str): ref_string type. (cpe22 or cpe23)
222
222
223
223
Returns:
224
224
- bool: True if the ref_string parameter is a valid purl or cpe string, False otherwise.
225
225
226
226
"""
227
227
string_pattern : str
228
- if string_type == "purl" :
229
- string_pattern = r"^(?P<scheme>.+):(?P<type>.+)/(?P<namespace>.+)/(?P<name>.+)@(?P<version>.+)\??(?P<qualifiers>.*)#?(?P<subpath>.*)$"
230
-
231
- elif string_type == "cpe23" :
228
+ if string_type == "cpe23" :
232
229
string_pattern = r"^cpe:2\.3:[aho\*\-](:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?\!\"#\$%&'\(\)\+,\-\.\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\*\-]))(:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?\!\"#\$%&'\(\)\+,\-\.\/:;<=>@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){4}"
233
230
234
231
elif string_type == "cpe22" :
@@ -377,7 +374,8 @@ def parse_ext_ref(self, ext_ref) -> (str | None, str | None, str | None):
377
374
elif ref_type == "cpe22Type" and self .is_valid_string ("cpe22" , ref_string ):
378
375
decoded ["cpe22Type" ] = decode_cpe22 (ref_string )
379
376
380
- elif ref_type == "purl" and self .is_valid_string ("purl" , ref_string ):
377
+ elif ref_type == "purl" :
378
+ # Validation of purl is performed implicitly within the decode_purl function
381
379
decoded ["purl" ] = self .decode_purl (ref_string )
382
380
383
381
# No ext-ref matches, return none
0 commit comments