From 7bfa0bd74df756552e0f28e2c0e39f75d574ce17 Mon Sep 17 00:00:00 2001 From: Tushar Goel Date: Tue, 21 Jan 2025 18:05:59 +0530 Subject: [PATCH] Adress review comments Signed-off-by: Tushar Goel --- vulnerabilities/utils.py | 2 +- vulnerabilities/views.py | 24 ------------------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/vulnerabilities/utils.py b/vulnerabilities/utils.py index 32cfcbc02..d9a3c7e04 100644 --- a/vulnerabilities/utils.py +++ b/vulnerabilities/utils.py @@ -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: diff --git a/vulnerabilities/views.py b/vulnerabilities/views.py index 4346ce2e0..a2df48634 100644 --- a/vulnerabilities/views.py +++ b/vulnerabilities/views.py @@ -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"