1010import hashlib
1111import json
1212import logging
13+ import typing
1314from contextlib import suppress
1415from functools import cached_property
1516from typing import Optional
@@ -522,7 +523,13 @@ def for_purl(self, purl):
522523 """
523524 Return a queryset matching the ``purl`` Package URL.
524525 """
525- return self .filter (** purl_to_dict (purl ))
526+ return self .filter (package_url = purl )
527+
528+ def for_purls (self , purls = ()):
529+ """
530+ Return a queryset of Packages matching a list of PURLs.
531+ """
532+ return self .filter (package_url__in = purls ).distinct ()
526533
527534 def with_cpes (self ):
528535 """
@@ -532,24 +539,21 @@ def with_cpes(self):
532539
533540 def for_cpe (self , cpe ):
534541 """
535- Return a queryset of Vulnerability that have the ``cpe`` as an NVD CPE reference.
542+ Return a queryset of Packages that have the ``cpe`` as an NVD CPE reference.
536543 """
537544 return self .filter (vulnerabilities__vulnerabilityreference__reference_id__exact = cpe )
538545
539546 def with_cves (self ):
540547 """
541- Return a queryset of Vulnerability that have one or more NVD CVE aliases.
548+ Return a queryset of Packages that have one or more NVD CVE aliases.
542549 """
543550 return self .filter (vulnerabilities__aliases__alias__startswith = "CVE" )
544551
545552 def for_cve (self , cve ):
546553 """
547- Return a queryset of Vulnerability that have the the NVD CVE ``cve`` as an alias.
554+ Return a queryset of Packages that have the NVD CVE ``cve`` as a vulnerability alias.
548555 """
549- return self .filter (vulnerabilities__vulnerabilityreference__reference_id__exact = cve )
550-
551- def for_purls (self , purls = []):
552- return Package .objects .filter (package_url__in = purls ).distinct ()
556+ return self .filter (vulnerabilities__aliases__alias = cve )
553557
554558 def with_is_vulnerable (self ):
555559 """
0 commit comments