|
32 | 32 | from vulnerabilities.forms import VulnerabilitySearchForm |
33 | 33 | from vulnerabilities.severity_systems import EPSS |
34 | 34 | from vulnerabilities.severity_systems import SCORING_SYSTEMS |
35 | | -from vulnerabilities.utils import get_purl_version_class |
36 | 35 | from vulnerablecode import __version__ as VULNERABLECODE_VERSION |
37 | 36 | from vulnerablecode.settings import env |
38 | 37 |
|
39 | 38 | PAGE_SIZE = 20 |
40 | 39 |
|
41 | 40 |
|
42 | | -def purl_sort_key(purl: models.Package): |
43 | | - """ |
44 | | - Return a sort key for the built-in sorted() function when sorting a list |
45 | | - of Package objects. If the Package ``type`` is supported by univers, apply |
46 | | - the univers version class to the Package ``version``, and otherwise use the |
47 | | - ``version`` attribute as is. |
48 | | - """ |
49 | | - purl_version_class = get_purl_version_class(purl) |
50 | | - purl_sort_version = purl.version |
51 | | - if purl_version_class: |
52 | | - purl_sort_version = purl_version_class(purl.version) |
53 | | - return (purl.type, purl.namespace, purl.name, purl_sort_version, purl.qualifiers, purl.subpath) |
54 | | - |
55 | | - |
56 | | -def get_purl_version_class(purl: models.Package): |
57 | | - RANGE_CLASS_BY_SCHEMES["apk"] = AlpineLinuxVersionRange |
58 | | - purl_version_class = None |
59 | | - check_version_class = RANGE_CLASS_BY_SCHEMES.get(purl.type, None) |
60 | | - if check_version_class: |
61 | | - purl_version_class = check_version_class.version_class |
62 | | - return purl_version_class |
63 | | - |
64 | | - |
65 | 41 | class PackageSearch(ListView): |
66 | 42 | model = models.Package |
67 | 43 | template_name = "packages.html" |
|
0 commit comments