Skip to content
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: 6 additions & 2 deletions docs/content/en/open_source/upgrading/2.50.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
title: 'Upgrading to DefectDojo Version 2.50.x'
toc_hide: true
weight: -20250804
description: No special instructions.
description: Dropped support for time_zone in System settings.
---
There are no special instructions for upgrading to 2.50.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.50.0) for the contents of the release.

To simplify the management of the DefectDojo application, it is not necessary to set the time zone in two places (environmental variables and system settings). From now on, environmental variable is supported.
Comment thread
kiblik marked this conversation as resolved.
Please check that the environmental variable `DD_TIME_ZONE` is set based on your satisfaction. Any [TZ identifier](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is a valid value. Default value is `UTC`.

There are other instructions for upgrading to 2.50.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.50.0) for the contents of the release.
15 changes: 15 additions & 0 deletions dojo/db_migrations/0241_remove_system_settings_time_zone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 5.1.11 on 2025-08-15 16:30
from django.db import migrations

class Migration(migrations.Migration):

dependencies = [
('dojo', '0240_jira_instance_password_help_text_fix'),
]

operations = [
migrations.RemoveField(
model_name='system_settings',
name='time_zone',
),
]
23 changes: 8 additions & 15 deletions dojo/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import decimal
import logging
import warnings
import zoneinfo
from datetime import datetime, timedelta

import six
Expand All @@ -14,7 +13,7 @@
from django.contrib.contenttypes.models import ContentType
from django.db.models import Count, JSONField, Q
from django.forms import HiddenInput
from django.utils import timezone
from django.utils.timezone import now, tzinfo
from django.utils.translation import gettext_lazy as _
from django_filters import (
BooleanFilter,
Expand Down Expand Up @@ -97,8 +96,6 @@

logger = logging.getLogger(__name__)

local_tz = zoneinfo.ZoneInfo(get_system_setting("time_zone"))

BOOLEAN_CHOICES = (("false", "No"), ("true", "Yes"))
EARLIEST_FINDING = None

Expand All @@ -124,10 +121,6 @@ def vulnerability_id_filter(queryset, name, value):
return queryset.filter(id__in=ids)


def now():
return datetime.today().replace(tzinfo=local_tz)


class NumberInFilter(filters.BaseInFilter, filters.NumberFilter):
pass

Expand Down Expand Up @@ -200,7 +193,7 @@ def filter(self, qs, value):
earliest_finding = get_earliest_finding(qs)
if earliest_finding is not None:
start_date = datetime.combine(
earliest_finding.date, datetime.min.time()).replace(tzinfo=local_tz)
earliest_finding.date, datetime.min.time()).replace(tzinfo=tzinfo())
self.start_date = _truncate(start_date - timedelta(days=1))
self.end_date = _truncate(now() + timedelta(days=1))
try:
Expand All @@ -216,7 +209,7 @@ def any(self, qs, name):

def sla_satisfied(self, qs, name):
# return findings that have an sla expiration date after today or no sla expiration date
return qs.filter(Q(sla_expiration_date__isnull=True) | Q(sla_expiration_date__gt=timezone.now().date()))
return qs.filter(Q(sla_expiration_date__isnull=True) | Q(sla_expiration_date__gt=now().date()))

def sla_violated(self, qs, name):
# return active findings that have an sla expiration date before today
Expand All @@ -229,7 +222,7 @@ def sla_violated(self, qs, name):
risk_accepted=False,
is_mitigated=False,
mitigated=None,
) & Q(sla_expiration_date__lt=timezone.now().date()),
) & Q(sla_expiration_date__lt=now().date()),
)

options = {
Expand Down Expand Up @@ -824,22 +817,22 @@ def any(self, qs, name):
earliest_finding = get_earliest_finding(qs)
if earliest_finding is not None:
start_date = datetime.combine(
earliest_finding.date, datetime.min.time()).replace(tzinfo=local_tz)
earliest_finding.date, datetime.min.time()).replace(tzinfo=tzinfo())
self.start_date = _truncate(start_date - timedelta(days=1))
self.end_date = _truncate(now() + timedelta(days=1))
return qs.all()
return None

def current_month(self, qs, name):
self.start_date = datetime(now().year, now().month, 1, 0, 0, 0).replace(tzinfo=local_tz)
self.start_date = datetime(now().year, now().month, 1, 0, 0, 0).replace(tzinfo=tzinfo())
self.end_date = now()
return qs.filter(**{
f"{name}__year": self.start_date.year,
f"{name}__month": self.start_date.month,
})

def current_year(self, qs, name):
self.start_date = datetime(now().year, 1, 1, 0, 0, 0).replace(tzinfo=local_tz)
self.start_date = datetime(now().year, 1, 1, 0, 0, 0).replace(tzinfo=tzinfo())
self.end_date = now()
return qs.filter(**{
f"{name}__year": now().year,
Expand Down Expand Up @@ -890,7 +883,7 @@ def filter(self, qs, value):
earliest_finding = get_earliest_finding(qs)
if earliest_finding is not None:
start_date = datetime.combine(
earliest_finding.date, datetime.min.time()).replace(tzinfo=local_tz)
earliest_finding.date, datetime.min.time()).replace(tzinfo=tzinfo())
self.start_date = _truncate(start_date - timedelta(days=1))
self.end_date = _truncate(now() + timedelta(days=1))
try:
Expand Down
1 change: 0 additions & 1 deletion dojo/fixtures/defect_dojo_sample_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@
"retroactive_false_positive_history": false,
"url_prefix": "",
"team_name": "",
"time_zone": "UTC",
"enable_product_grade": true,
"product_grade": "def grade_product(crit, high, med, low):\r\n health=100\r\n if crit > 0:\r\n health = 40\r\n health = health - ((crit - 1) * 5)\r\n if high > 0:\r\n if health == 100:\r\n health = 60\r\n health = health - ((high - 1) * 3)\r\n if med > 0:\r\n if health == 100:\r\n health = 80\r\n health = health - ((med - 1) * 2)\r\n if low > 0:\r\n if health == 100:\r\n health = 95\r\n health = health - low\r\n\r\n if health < 5:\r\n health = 5\r\n\r\n return health",
"product_grade_a": 90,
Expand Down
1 change: 0 additions & 1 deletion dojo/fixtures/dojo_testdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@
"max_dupes": 1,
"slack_username": "",
"enable_msteams_notifications": false,
"time_zone": "UTC",
"enable_deduplication": true,
"delete_duplicates": false,
"slack_channel": "",
Expand Down
1 change: 0 additions & 1 deletion dojo/fixtures/system_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"enable_deduplication": false,
"enable_jira": false,
"url_prefix": "",
"time_zone": "UTC",
"product_grade": "def grade_product(crit, high, med, low):\r\n health=100\r\n if crit > 0:\r\n health = 40\r\n health = health - ((crit - 1) * 5)\r\n if high > 0:\r\n if health == 100:\r\n health = 60\r\n health = health - ((high - 1) * 3)\r\n if med > 0:\r\n if health == 100:\r\n health = 80\r\n health = health - ((med - 1) * 2)\r\n if low > 0:\r\n if health == 100:\r\n health = 95\r\n health = health - low\r\n\r\n if health < 5:\r\n health = 5\r\n\r\n return health",
"product_grade_a": 90,
"product_grade_b": 80,
Expand Down
4 changes: 0 additions & 4 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import re
import warnings
import zoneinfo
from contextlib import suppress
from datetime import datetime, timedelta
from decimal import Decimal
Expand Down Expand Up @@ -437,9 +436,6 @@ class System_Settings(models.Model):

url_prefix = models.CharField(max_length=300, default="", blank=True, help_text=_("URL prefix if DefectDojo is installed in it's own virtual subdirectory."))
team_name = models.CharField(max_length=100, default="", blank=True)
time_zone = models.CharField(max_length=50,
choices=[(tz, tz) for tz in zoneinfo.available_timezones()],
default="UTC", blank=False)
enable_product_grade = models.BooleanField(default=False, verbose_name=_("Enable Product Grading"), help_text=_("Displays a grade letter next to a product to show the overall health."))
product_grade = models.CharField(max_length=800, blank=True)
product_grade_a = models.IntegerField(default=90,
Expand Down