@@ -214,21 +214,18 @@ def get_vendor(self, product: str) -> list:
214214
215215 def is_valid_string (self , string_type : str , ref_string : str ) -> bool :
216216 """
217- Validate the PURL, CPE string is the correct form.
217+ Validate the CPE string is the correct form.
218218
219219 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)
222222
223223 Returns:
224224 - bool: True if the ref_string parameter is a valid purl or cpe string, False otherwise.
225225
226226 """
227227 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" :
232229 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}"
233230
234231 elif string_type == "cpe22" :
@@ -377,7 +374,8 @@ def parse_ext_ref(self, ext_ref) -> (str | None, str | None, str | None):
377374 elif ref_type == "cpe22Type" and self .is_valid_string ("cpe22" , ref_string ):
378375 decoded ["cpe22Type" ] = decode_cpe22 (ref_string )
379376
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
381379 decoded ["purl" ] = self .decode_purl (ref_string )
382380
383381 # No ext-ref matches, return none
0 commit comments