From 689f40c4fb744db74c6c50e119685af31ea7a908 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Mon, 2 Mar 2026 23:28:15 +0000 Subject: [PATCH 1/2] minor changes: django.conf.settings over dojo.settings --- dojo/apps.py | 7 +++++++ dojo/location/models.py | 6 ------ dojo/reports/widgets.py | 2 +- wsgi.py | 35 ----------------------------------- 4 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 wsgi.py diff --git a/dojo/apps.py b/dojo/apps.py index 96b8c87af34..d0b8e71c8f0 100644 --- a/dojo/apps.py +++ b/dojo/apps.py @@ -1,6 +1,7 @@ import logging from django.apps import AppConfig +from django.conf import settings from django.core.checks import register as register_check from django.db import models from watson import search as watson @@ -16,6 +17,12 @@ class DojoAppConfig(AppConfig): verbose_name = "Defect Dojo" def ready(self): + if settings.ENABLE_AUDITLOG: + from auditlog.registry import auditlog # noqa: PLC0415 raised: AppRegistryNotReady + + from dojo.location.models import Location # noqa: PLC0415 raised: AppRegistryNotReady + + auditlog.register(Location) # we need to initializer waston here because in models.py is to early if we want add extra fields to index # logger.info('ready(): initializing watson') # commented out ^ as it prints in manage.py dumpdata, docker logs and many other places diff --git a/dojo/location/models.py b/dojo/location/models.py index b0446673f33..3ab313ace87 100644 --- a/dojo/location/models.py +++ b/dojo/location/models.py @@ -2,7 +2,6 @@ from typing import TYPE_CHECKING, Self, TypeVar -from auditlog.registry import auditlog from django.db import transaction from django.db.models import ( CASCADE, @@ -34,7 +33,6 @@ ) from dojo.location.status import FindingLocationStatus, ProductLocationStatus from dojo.models import Dojo_User, Finding, Product, _manage_inherited_tags, copy_model_util -from dojo.settings import settings from dojo.tools.locations import LocationAssociationData if TYPE_CHECKING: @@ -454,7 +452,3 @@ class Meta: def __str__(self) -> str: """Return the string representation of a LocationProductReference.""" return f"{self.location} - Product: {self.product} ({self.status})" - - -if settings.ENABLE_AUDITLOG: - auditlog.register(Location) diff --git a/dojo/reports/widgets.py b/dojo/reports/widgets.py index e71a7168b70..aa88d9a4884 100644 --- a/dojo/reports/widgets.py +++ b/dojo/reports/widgets.py @@ -3,6 +3,7 @@ from collections import OrderedDict from django import forms +from django.conf import settings from django.forms import Widget from django.forms.utils import flatatt from django.http import QueryDict @@ -23,7 +24,6 @@ from dojo.location.status import FindingLocationStatus from dojo.models import Endpoint, Finding from dojo.reports.queries import prefetch_related_endpoints_for_report, prefetch_related_findings_for_report -from dojo.settings import settings from dojo.url.filters import URLFilter from dojo.utils import get_page_items, get_system_setting, get_words_for_field diff --git a/wsgi.py b/wsgi.py deleted file mode 100644 index 19f8d609d0b..00000000000 --- a/wsgi.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -WSGI config for dojo project. - -This module contains the WSGI application used by Django's development server -and any production WSGI deployments. It should expose a module-level variable -named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover -this application via the ``WSGI_APPLICATION`` setting. - -Usually you will have the standard Django WSGI application here, but it also -might make sense to replace the whole Django WSGI application with a custom one -that later delegates to the Django one. For example, you could introduce WSGI -middleware here, or combine a Django application with an application of another -framework. - -""" -import os - -from django.core.wsgi import get_wsgi_application -from django.urls import get_resolver - -from dojo.settings.settings import ROOT_URLCONF - -# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks -# if running multiple sites in the same mod_wsgi process. To fix this, use -# mod_wsgi daemon mode with each site in its own daemon process, or use -# os.environ["DJANGO_SETTINGS_MODULE"] = "dojo.settings" -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dojo.settings.settings") - -# This application object is used by any WSGI server configured to use this -# file. This includes Django's development server, if the WSGI_APPLICATION -# setting points here. -application = get_wsgi_application() - -# Preload the application code by preloading the URLs configuration -get_resolver(ROOT_URLCONF).url_patterns # noqa: B018 From 9f7f37ff5e0447d6f68f9bffd63b975daa0f7265 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Tue, 3 Mar 2026 07:57:09 +0000 Subject: [PATCH 2/2] missed bit --- Dockerfile.django-alpine | 2 +- Dockerfile.django-debian | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.django-alpine b/Dockerfile.django-alpine index 4f26ae3c497..6235c0469bb 100644 --- a/Dockerfile.django-alpine +++ b/Dockerfile.django-alpine @@ -78,7 +78,7 @@ COPY \ docker/reach_broker.sh \ docker/certs/* \ / -COPY wsgi.py manage.py ./ +COPY manage.py ./ COPY dojo/ ./dojo/ # Add extra fixtures to docker image which are loaded by the initializer diff --git a/Dockerfile.django-debian b/Dockerfile.django-debian index 61aeffd2fe4..c19bc30baf3 100644 --- a/Dockerfile.django-debian +++ b/Dockerfile.django-debian @@ -81,7 +81,7 @@ COPY \ docker/reach_broker.sh \ docker/certs/* \ / -COPY wsgi.py manage.py ./ +COPY manage.py ./ COPY dojo/ ./dojo/ # Add extra fixtures to docker image which are loaded by the initializer