diff --git a/packagedb/api.py b/packagedb/api.py index b633b72d..3a2aa981 100644 --- a/packagedb/api.py +++ b/packagedb/api.py @@ -695,7 +695,10 @@ def get_resolved_purls(packages): for items in packages or []: purl = items.get('purl') vers = items.get('vers') - + + if not purl: + continue + try: parsed_purl = PackageURL.from_string(purl) except ValueError: @@ -706,6 +709,10 @@ def get_resolved_purls(packages): unique_resolved_purls.add(purl) continue + if not vers: + unsupported_purls.add(purl) + continue + if resolved:= resolve_versions(parsed_purl, vers): unique_resolved_purls.update(resolved) else: @@ -720,6 +727,9 @@ def resolve_versions(parsed_purl, vers): Take version-less purl along with vers range and return list of all the purls satisfying the vers range. """ + if not parsed_purl or not vers: + return + try: version_range = VersionRange.from_string(vers) except ValueError: