Skip to content

Commit

Permalink
Adress review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Goel <[email protected]>
  • Loading branch information
TG1999 committed Jan 21, 2025
1 parent ba20954 commit 7bfa0bd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
2 changes: 1 addition & 1 deletion vulnerabilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def normalize_purl(purl: Union[PackageURL, str]):


def get_purl_version_class(purl):
RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange
RANGE_CLASS_BY_SCHEMES["apk"] = AlpineLinuxVersionRange
purl_version_class = None
check_version_class = RANGE_CLASS_BY_SCHEMES.get(purl.type, None)
if check_version_class:
Expand Down
24 changes: 0 additions & 24 deletions vulnerabilities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,12 @@
from vulnerabilities.forms import VulnerabilitySearchForm
from vulnerabilities.severity_systems import EPSS
from vulnerabilities.severity_systems import SCORING_SYSTEMS
from vulnerabilities.utils import get_purl_version_class
from vulnerablecode import __version__ as VULNERABLECODE_VERSION
from vulnerablecode.settings import env

PAGE_SIZE = 20


def purl_sort_key(purl: models.Package):
"""
Return a sort key for the built-in sorted() function when sorting a list
of Package objects. If the Package ``type`` is supported by univers, apply
the univers version class to the Package ``version``, and otherwise use the
``version`` attribute as is.
"""
purl_version_class = get_purl_version_class(purl)
purl_sort_version = purl.version
if purl_version_class:
purl_sort_version = purl_version_class(purl.version)
return (purl.type, purl.namespace, purl.name, purl_sort_version, purl.qualifiers, purl.subpath)


def get_purl_version_class(purl: models.Package):
RANGE_CLASS_BY_SCHEMES["apk"] = AlpineLinuxVersionRange
purl_version_class = None
check_version_class = RANGE_CLASS_BY_SCHEMES.get(purl.type, None)
if check_version_class:
purl_version_class = check_version_class.version_class
return purl_version_class


class PackageSearch(ListView):
model = models.Package
template_name = "packages.html"
Expand Down

0 comments on commit 7bfa0bd

Please sign in to comment.