Skip to content

Commit 8655614

Browse files
committed
feat(docker): Use Python 3.12 in docker images
Try to exclude pkg_resources warning Exclude datetime.datetime.utcnow Apply regex Fix regex Be more specific for filterwarnings Correct module name Try to exclude only based on module
1 parent 218a29a commit 8655614

File tree

10 files changed

+17
-17
lines changed

10 files changed

+17
-17
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This checklist is for your information.
2626
- [ ] Bugfixes should be submitted against the `bugfix` branch.
2727
- [ ] Give a meaningful name to your PR, as it may end up being used in the release notes.
2828
- [ ] Your code is flake8 compliant.
29-
- [ ] Your code is python 3.11 compliant.
29+
- [ ] Your code is python 3.12 compliant.
3030
- [ ] If this is a new feature and not a bug fix, you've included the proper documentation in the docs at https://github.com/DefectDojo/django-DefectDojo/tree/dev/docs as part of this PR.
3131
- [ ] Model changes must include the necessary migrations in the dojo/db_migrations folder.
3232
- [ ] Add applicable tests to the unit tests.

Dockerfile.django-alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Dockerfile.nginx to use the caching mechanism of Docker.
66

77
# Ref: https://devguide.python.org/#branchstatus
8-
FROM python:3.11.13-alpine3.22@sha256:8d8c6d3808243160605925c2a7ab2dc5c72d0e75651699b0639143613e0855b8 AS base
8+
FROM python:3.12.11-alpine3.22@sha256:02a73ead8397e904cea6d17e18516f1df3590e05dc8823bd5b1c7f849227d272 AS base
99
FROM base AS build
1010
WORKDIR /app
1111
RUN \

Dockerfile.django-debian

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Dockerfile.nginx to use the caching mechanism of Docker.
66

77
# Ref: https://devguide.python.org/#branchstatus
8-
FROM python:3.11.13-slim-trixie@sha256:1d6131b5d479888b43200645e03a78443c7157efbdb730e6b48129740727c312 AS base
8+
FROM python:3.12.11-slim-trixie@sha256:d67a7b66b989ad6b6d6b10d428dcc5e0bfc3e5f88906e67d490c4d3daac57047 AS base
99
FROM base AS build
1010
WORKDIR /app
1111
RUN \

Dockerfile.integration-tests-debian

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
FROM openapitools/openapi-generator-cli:v7.15.0@sha256:509f01c3c7eee9d1ad286506a7b6aa4624a95b410be9a238a306d209e900621f AS openapitools
55
# currently only supports x64, no arm yet due to chrome and selenium dependencies
6-
FROM python:3.11.13-slim-trixie@sha256:1d6131b5d479888b43200645e03a78443c7157efbdb730e6b48129740727c312 AS build
6+
FROM python:3.12.11-slim-trixie@sha256:d67a7b66b989ad6b6d6b10d428dcc5e0bfc3e5f88906e67d490c4d3daac57047 AS build
77
WORKDIR /app
88
RUN \
99
apt-get -y update && \

Dockerfile.nginx-alpine

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
# Dockerfile.django-alpine to use the caching mechanism of Docker.
66

77
# Ref: https://devguide.python.org/#branchstatus
8-
FROM python:3.11.13-alpine3.22@sha256:8d8c6d3808243160605925c2a7ab2dc5c72d0e75651699b0639143613e0855b8 AS base
9-
8+
FROM python:3.12.11-alpine3.22@sha256:02a73ead8397e904cea6d17e18516f1df3590e05dc8823bd5b1c7f849227d272 AS base
109
FROM base AS build
1110
WORKDIR /app
1211
RUN \

dojo/jira_link/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def post(self, request):
387387
create_notification(
388388
event="jira_config_added",
389389
title=f"New addition of JIRA: {jform.cleaned_data.get('configuration_name')}",
390-
description=f"JIRA \"{jform.cleaned_data.get('configuration_name')}\" was added by {request.user}",
390+
description=f'JIRA "{jform.cleaned_data.get('configuration_name')}" was added by {request.user}',
391391
url=request.build_absolute_uri(reverse("jira")))
392392

393393
return HttpResponseRedirect(reverse("jira"))
@@ -432,7 +432,7 @@ def post(self, request):
432432
create_notification(
433433
event="jira_config_added",
434434
title=f"New addition of JIRA: {jform.cleaned_data.get('configuration_name')}",
435-
description=f"JIRA \"{jform.cleaned_data.get('configuration_name')}\" was added by {request.user}",
435+
description=f'JIRA "{jform.cleaned_data.get('configuration_name')}" was added by {request.user}',
436436
url=request.build_absolute_uri(reverse("jira")))
437437

438438
return HttpResponseRedirect(reverse("jira"))
@@ -486,7 +486,7 @@ def post(self, request, jid=None):
486486
create_notification(
487487
event="jira_config_edited",
488488
title=f"Edit of JIRA: {jform.cleaned_data.get('configuration_name')}",
489-
description=f"JIRA \"{jform.cleaned_data.get('configuration_name')}\" was edited by {request.user}",
489+
description=f'JIRA "{jform.cleaned_data.get('configuration_name')}" was edited by {request.user}',
490490
url=request.build_absolute_uri(reverse("jira")))
491491

492492
return HttpResponseRedirect(reverse("jira"))

dojo/metrics/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def get_date_range(
343343
return start_date, end_date
344344

345345

346-
def severity_count(
346+
def severity_count[MetricsQuerySet: (QuerySet[Finding], QuerySet[Endpoint_Status])](
347347
queryset: MetricsQuerySet,
348348
method: str,
349349
expression: str,
@@ -407,7 +407,7 @@ def js_epoch(
407407
return int(d.timestamp()) * 1000
408408

409409

410-
def get_charting_data(
410+
def get_charting_data[MetricsQuerySet: (QuerySet[Finding], QuerySet[Endpoint_Status])](
411411
qs: MetricsQuerySet,
412412
start_date: date,
413413
period: MetricsPeriod,
@@ -470,7 +470,7 @@ def period_deltas(start_date, end_date):
470470
return weeks_between, months_between
471471

472472

473-
def aggregate_counts_by_period(
473+
def aggregate_counts_by_period[MetricsQuerySet: (QuerySet[Finding], QuerySet[Endpoint_Status])](
474474
qs: MetricsQuerySet,
475475
period: MetricsPeriod,
476476
metrics_type: MetricsType,
@@ -580,7 +580,7 @@ def get_closed_in_period_details(
580580
)
581581

582582

583-
def findings_queryset(
583+
def findings_queryset[MetricsQuerySet: (QuerySet[Finding], QuerySet[Endpoint_Status])](
584584
qs: MetricsQuerySet,
585585
) -> QuerySet[Finding]:
586586
"""

readme-docs/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Please use [these test scripts](../tests) to test your changes. These are the sc
5656
For changes that require additional settings, you can now use local_settings.py file. See the logging section below for more information.
5757

5858
## Python3 Version
59-
For compatibility reasons, the code in dev branch should be python3.11 compliant.
59+
For compatibility reasons, the code in dev branch should be python3.12 compliant.
6060

6161
## Database migrations
6262
When changes are made to the database model, a database migration is needed. This migration can be generated using something like
@@ -82,7 +82,7 @@ DefectDojo.
8282

8383
0. Pull requests should be submitted to the `dev` or `bugfix` branch.
8484

85-
0. In dev branch, the code should be python 3.11 compliant.
85+
0. In dev branch, the code should be python 3.12 compliant.
8686

8787
[dojo_settings]: /dojo/settings/settings.dist.py "DefectDojo settings file"
8888
[pep8]: https://www.python.org/dev/peps/pep-0008/ "PEP8"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ PyYAML==6.0.2
7676
pyopenssl==25.1.0
7777
parameterized==0.9.0
7878
watchdog==6.0.0 # only needed for development, but would require some docker refactoring if we want to exclude it for production images
79+
setuptools==80.9.0

ruff.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Always generate Python 3.11-compatible code.
2-
target-version = "py311"
1+
# Always generate Python 3.12-compatible code.
2+
target-version = "py312"
33

44
# Same as Black.
55
line-length = 120

0 commit comments

Comments
 (0)