10000 Fix 1387 by TG1999 · Pull Request #1389 · aboutcode-org/vulnerablecode · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix 1387 #1389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion vulnerabilities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
from rest_framework.authtoken.models import Token
from univers import versions
from univers.version_range import RANGE_CLASS_BY_SCHEMES
from univers.version_range import AlpineLinuxVersionRange
from univers.versions import Version

from vulnerabilities import utils
from vulnerabilities.severity_systems import SCORING_SYSTEMS
Expand Down Expand Up @@ -645,7 +647,11 @@ def sort_by_version(self, packages):

@property
def version_class(self):
return RANGE_CLASS_BY_SCHEMES[self.type].version_class
RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange
range_class = RANGE_CLASS_BY_SCHEMES.get(self.type)
if not range_class:
return Version
return range_class.version_class

@property
def current_version(self):
Expand Down
4 changes: 2 additions & 2 deletions vulnerabilities/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ def test_univers_version_class(self):
pypi_package_version = RANGE_CLASS_BY_SCHEMES[pypi_package.type].version_class
assert pypi_package_version == versions.PypiVersion

RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange
alpine_version = RANGE_CLASS_BY_SCHEMES["alpine"].version_class
alpine_package = models.Package.objects.create(type="alpine", name="lxml", version="0.9")
alpine_version = RANGE_CLASS_BY_SCHEMES[alpine_package.type].version_class
assert alpine_version == versions.AlpineLinuxVersion

def test_sort_by_version(self):
Expand Down
0