Skip to content

Commit 07bec90

Browse files
committed
Upgrade Django, packageurl-python, and other dependencies
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 97a890b commit 07bec90

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

scanpipe/models.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
from packagedcode.utils import get_base_purl
7979
from packageurl import PackageURL
8080
from packageurl import normalize_qualifiers
81+
from packageurl.contrib.django.models import PACKAGE_URL_FIELDS
8182
from packageurl.contrib.django.models import PackageURLMixin
8283
from packageurl.contrib.django.models import PackageURLQuerySetMixin
8384
from rest_framework.authtoken.models import Token
@@ -105,10 +106,6 @@ class RunNotAllowedToStart(Exception):
105106
"""Previous Runs have not completed yet."""
106107

107108

108-
# PackageURL._fields
109-
PURL_FIELDS = ("type", "namespace", "name", "version", "qualifiers", "subpath")
110-
111-
112109
class UUIDPKModel(models.Model):
113110
uuid = models.UUIDField(
114111
verbose_name=_("UUID"),
@@ -1616,7 +1613,7 @@ def update_from_data(self, data, override=False):
16161613
skip_reasons = [
16171614
value in EMPTY_VALUES,
16181615
field_name not in model_fields,
1619-
field_name in PURL_FIELDS,
1616+
field_name in PACKAGE_URL_FIELDS,
16201617
]
16211618
if any(skip_reasons):
16221619
continue
@@ -2040,7 +2037,7 @@ def prefetch_for_serializer(self):
20402037
Prefetch(
20412038
"discovered_packages",
20422039
queryset=DiscoveredPackage.objects.only(
2043-
"package_uid", "uuid", *PURL_FIELDS
2040+
"package_uid", "uuid", *PACKAGE_URL_FIELDS
20442041
),
20452042
),
20462043
)
@@ -2924,10 +2921,6 @@ def vulnerable(self):
29242921
class DiscoveredPackageQuerySet(
29252922
VulnerabilityQuerySetMixin, PackageURLQuerySetMixin, ProjectRelatedQuerySet
29262923
):
2927-
def order_by_purl(self):
2928-
"""Order by Package URL fields."""
2929-
return self.order_by("type", "namespace", "name", "version")
2930-
29312924
def with_resources_count(self):
29322925
count_subquery = Subquery(
29332926
self.filter(pk=OuterRef("pk"))
@@ -2937,12 +2930,12 @@ def with_resources_count(self):
29372930
)
29382931
return self.annotate(resources_count=count_subquery)
29392932

2940-
def only_purl_fields(self):
2933+
def only_package_url_fields(self):
29412934
"""
29422935
Only select and return the UUID and PURL fields.
29432936
Minimum requirements to render a Package link in the UI.
29442937
"""
2945-
return self.only("uuid", *PURL_FIELDS)
2938+
return self.only("uuid", *PACKAGE_URL_FIELDS)
29462939

29472940

29482941
class AbstractPackage(models.Model):
@@ -3814,7 +3807,7 @@ def normalize_package_url_data(purl_mapping, ignore_nulls=False):
38143807
purl data can be executed.
38153808
"""
38163809
normalized_purl_mapping = {}
3817-
for field_name in PURL_FIELDS:
3810+
for field_name in PACKAGE_URL_FIELDS:
38183811
value = purl_mapping.get(field_name)
38193812
if field_name == "qualifiers":
38203813
value = normalize_qualifiers(value, encode=True)

scanpipe/views.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import saneyaml
6060
import xlsxwriter
6161
from django_filters.views import FilterView
62+
from packageurl.contrib.django.models import PACKAGE_URL_FIELDS
6263

6364
from scancodeio.auth import ConditionalLoginRequired
6465
from scancodeio.auth import conditional_login_required
@@ -79,7 +80,6 @@
7980
from scanpipe.forms import ProjectCloneForm
8081
from scanpipe.forms import ProjectForm
8182
from scanpipe.forms import ProjectSettingsForm
82-
from scanpipe.models import PURL_FIELDS
8383
from scanpipe.models import CodebaseRelation
8484
from scanpipe.models import CodebaseResource
8585
from scanpipe.models import DiscoveredDependency
@@ -1375,7 +1375,7 @@ class CodebaseResourceListView(
13751375
prefetch_related = [
13761376
Prefetch(
13771377
"discovered_packages",
1378-
queryset=DiscoveredPackage.objects.only_purl_fields(),
1378+
queryset=DiscoveredPackage.objects.only_package_url_fields(),
13791379
)
13801380
]
13811381
table_columns = [
@@ -1483,7 +1483,7 @@ def get_queryset(self):
14831483
.only(
14841484
"uuid",
14851485
"package_uid",
1486-
*PURL_FIELDS,
1486+
*PACKAGE_URL_FIELDS,
14871487
"project",
14881488
"primary_language",
14891489
"declared_license_expression",
@@ -1492,7 +1492,7 @@ def get_queryset(self):
14921492
"affected_by_vulnerabilities",
14931493
)
14941494
.with_resources_count()
1495-
.order_by_purl()
1495+
.order_by_package_url()
14961496
)
14971497

14981498
def get_context_data(self, **kwargs):
@@ -1514,10 +1514,13 @@ class DiscoveredDependencyListView(
15141514
template_name = "scanpipe/dependency_list.html"
15151515
paginate_by = settings.SCANCODEIO_PAGINATE_BY.get("dependency", 100)
15161516
prefetch_related = [
1517-
Prefetch("for_package", queryset=DiscoveredPackage.objects.only_purl_fields()),
1517+
Prefetch(
1518+
"for_package",
1519+
queryset=DiscoveredPackage.objects.only_package_url_fields(),
1520+
),
15181521
Prefetch(
15191522
"resolved_to_package",
1520-
queryset=DiscoveredPackage.objects.only_purl_fields(),
1523+
queryset=DiscoveredPackage.objects.only_package_url_fields(),
15211524
),
15221525
Prefetch(
15231526
"datafile_resource", queryset=CodebaseResource.objects.only("path", "name")
@@ -1658,7 +1661,7 @@ class CodebaseResourceDetailsView(
16581661
"discovered_packages",
16591662
queryset=DiscoveredPackage.objects.only(
16601663
"uuid",
1661-
*PURL_FIELDS,
1664+
*PACKAGE_URL_FIELDS,
16621665
"package_uid",
16631666
"affected_by_vulnerabilities",
16641667
"primary_language",
@@ -1858,7 +1861,7 @@ class DiscoveredPackageDetailsView(
18581861
),
18591862
Prefetch(
18601863
"declared_dependencies__resolved_to_package",
1861-
queryset=DiscoveredPackage.objects.only_purl_fields(),
1864+
queryset=DiscoveredPackage.objects.only_package_url_fields(),
18621865
),
18631866
]
18641867
tabset = {
@@ -2018,13 +2021,13 @@ class DiscoveredDependencyDetailsView(
20182021
Prefetch(
20192022
"for_package",
20202023
queryset=DiscoveredPackage.objects.only(
2021-
"uuid", *PURL_FIELDS, "package_uid", "project_id"
2024+
"uuid", *PACKAGE_URL_FIELDS, "package_uid", "project_id"
20222025
),
20232026
),
20242027
Prefetch(
20252028
"resolved_to_package",
20262029
queryset=DiscoveredPackage.objects.only(
2027-
"uuid", *PURL_FIELDS, "package_uid", "project_id"
2030+
"uuid", *PACKAGE_URL_FIELDS, "package_uid", "project_id"
20282031
),
20292032
),
20302033
Prefetch(

setup.cfg

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ packages=find:
4949
include_package_data = true
5050
zip_safe = false
5151
install_requires =
52-
importlib-metadata==7.2.1
52+
importlib-metadata==8.0.0
5353
setuptools==70.0.0
5454
# Django related
55-
Django==5.0.6
55+
Django==5.0.7
5656
django-environ==0.11.2
5757
django-crispy-forms==2.2
5858
crispy-bootstrap3==2024.1
5959
django-filter==24.2
6060
djangorestframework==3.15.2
6161
django-taggit==5.0.1
6262
# Database
63-
psycopg[binary]==3.1.19
63+
psycopg[binary]==3.2.1
6464
# wait_for_database Django management command
6565
django-probes==1.7.0
6666
# Task queue
6767
rq==1.16.2
6868
django-rq==2.10.2
69-
redis==5.0.6
69+
redis==5.0.7
7070
# WSGI server
7171
gunicorn==22.0.0
7272
# Docker
@@ -75,6 +75,7 @@ install_requires =
7575
scancode-toolkit[packages]==32.2.1
7676
extractcode[full]==31.0.0
7777
commoncode==31.2.1
78+
packageurl-python==0.15.4
7879
# FetchCode
7980
fetchcode-container==1.2.3.210512; sys_platform == "linux"
8081
# Inspectors
@@ -85,14 +86,14 @@ install_requires =
8586
aboutcode-toolkit==10.1.0
8687
# Utilities
8788
XlsxWriter==3.2.0
88-
openpyxl==3.1.4
89+
openpyxl==3.1.5
8990
requests==2.32.3
9091
gitpython==3.1.43
9192
# Profiling
9293
pyinstrument==4.6.2
9394
# CycloneDX
94-
cyclonedx-python-lib==7.5.0
95-
jsonschema==4.22.0
95+
cyclonedx-python-lib==7.5.1
96+
jsonschema==4.23.0
9697
# Font Awesome
9798
fontawesomefree==6.5.1
9899
# MatchCode-toolkit
@@ -116,15 +117,14 @@ dev =
116117
# Security analyzer
117118
bandit==1.7.9
118119
# Debug
119-
django-debug-toolbar==4.4.2
120+
django-debug-toolbar==4.4.6
120121
# Documentation
121-
Sphinx==7.3.7
122+
Sphinx==7.4.0
122123
sphinx-rtd-theme==2.0.0
123124
sphinx-rtd-dark-mode==1.3.0
124125
sphinxcontrib-django==2.5
125126
# Release
126127
bumpver==2023.1129
127-
twine==5.1.0
128128

129129
[options.entry_points]
130130
console_scripts =

0 commit comments

Comments
 (0)