From 1a6fb67317bff39f78044f3c87fb0f081f4e2974 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Wed, 7 Aug 2024 12:26:54 +0200 Subject: [PATCH 1/7] ruff --- dojo/metrics/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dojo/metrics/utils.py b/dojo/metrics/utils.py index 9a4b9f6bb04..81b0ab48c58 100644 --- a/dojo/metrics/utils.py +++ b/dojo/metrics/utils.py @@ -10,7 +10,6 @@ from django.contrib import messages from django.db import connection from django.db.models import Case, Count, F, IntegerField, Q, Sum, Value, When -from django.db.models.expressions import RawSQL from django.db.models.functions import Coalesce, ExtractDay, Now, TruncMonth, TruncWeek from django.db.models.query import QuerySet from django.http import HttpRequest From 4240982d3fa4b4cb6126d98830825ee244aa4813 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Wed, 7 Aug 2024 15:37:03 +0200 Subject: [PATCH 2/7] ruff --- dojo/metrics/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dojo/metrics/utils.py b/dojo/metrics/utils.py index 81b0ab48c58..72e78459be3 100644 --- a/dojo/metrics/utils.py +++ b/dojo/metrics/utils.py @@ -8,7 +8,6 @@ from dateutil.relativedelta import relativedelta from django.contrib import messages -from django.db import connection from django.db.models import Case, Count, F, IntegerField, Q, Sum, Value, When from django.db.models.functions import Coalesce, ExtractDay, Now, TruncMonth, TruncWeek from django.db.models.query import QuerySet From f3969c4d51f169dc4af3102a6306418783e73e59 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Mon, 21 Oct 2024 21:13:53 +0200 Subject: [PATCH 3/7] rebase --- dojo/settings/.settings.dist.py.sha256sum | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dojo/settings/.settings.dist.py.sha256sum diff --git a/dojo/settings/.settings.dist.py.sha256sum b/dojo/settings/.settings.dist.py.sha256sum deleted file mode 100644 index 5354615b1cc..00000000000 --- a/dojo/settings/.settings.dist.py.sha256sum +++ /dev/null @@ -1 +0,0 @@ -1b1f0b7210b79790c2bf1a3fdb62e24521544600bb4b460ed6a15cfd26f68640 From a9037223d313931278cfcddce49e563eadad62f6 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Tue, 19 Nov 2024 08:33:53 +0100 Subject: [PATCH 4/7] udpate --- dojo/settings/template-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/settings/template-env b/dojo/settings/template-env index ca068a10dc9..bbfc9e90ad9 100644 --- a/dojo/settings/template-env +++ b/dojo/settings/template-env @@ -10,7 +10,7 @@ DD_SECRET_KEY=#DD_SECRET_KEY# # Key for encrypting credentials in the manager DD_CREDENTIAL_AES_256_KEY=#DD_CREDENTIAL_AES_256_KEY# -# Database URL, options: postgres://, mysql://, sqlite://, to use unsafe characters encode with urllib.parse.encode +# Database URL, options: postgres://, to use unsafe characters encode with urllib.parse.encode DD_DATABASE_URL=#DD_DATABASE_URL# # Hosts/domain names that are valid for this site; From a94b64e8f232e88a1b9682ba656014695ee80854 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Thu, 5 Dec 2024 14:30:26 +0100 Subject: [PATCH 5/7] fix --- dojo/metrics/utils.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/dojo/metrics/utils.py b/dojo/metrics/utils.py index 72e78459be3..e2de37b6bce 100644 --- a/dojo/metrics/utils.py +++ b/dojo/metrics/utils.py @@ -537,18 +537,7 @@ def get_in_period_details( ).order_by("product_name") # Approach to age determination is db-engine dependent - if "postgresql" in connection.settings_dict["ENGINE"]: - age_detail = findings.annotate(age=ExtractDay(Coalesce("mitigated", Now()) - F("date"))) - elif "mysql" in connection.settings_dict["ENGINE"]: - # MySQL doesn't support durations natively and using an expression with subtraction yields unwanted results, - # so datediff() it is. - finding_table = Finding.objects.model._meta.db_table - age_detail = findings.annotate( - age=RawSQL(f"DATEDIFF(COALESCE({finding_table}.mitigated, CURRENT_TIMESTAMP), {finding_table}.date)", []), - ) - else: - raise ValueError - + age_detail = findings.annotate(age=ExtractDay(Coalesce("mitigated", Now()) - F("date"))) age_detail = age_detail.aggregate( age_under_30=Sum(Case(When(age__lte=30, then=Value(1))), default=Value(0), output_field=IntegerField()), age_31_60=Sum(Case(When(age__range=[31, 60], then=Value(1))), default=Value(0), output_field=IntegerField()), From 960f68aa7f32efa58aae0a610cdd12367bbf8a35 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Thu, 5 Dec 2024 14:33:17 +0100 Subject: [PATCH 6/7] fix --- dojo/settings/settings.dist.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dojo/settings/settings.dist.py b/dojo/settings/settings.dist.py index 9d364b353f9..b50ec84876f 100644 --- a/dojo/settings/settings.dist.py +++ b/dojo/settings/settings.dist.py @@ -1680,10 +1680,6 @@ def saml2_attrib_map_format(dict): # override filter to ensure sensitive variables are also hidden when DEBUG = True DEFAULT_EXCEPTION_REPORTER_FILTER = "dojo.settings.exception_filter.CustomExceptionReporterFilter" -# As we require `innodb_large_prefix = ON` for MySQL, we can silence the -# warning about large varchar with unique indices. -SILENCED_SYSTEM_CHECKS = ["mysql.E001"] - # Issue on benchmark : "The number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELD S" DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240 From a814e2c1f75445fe42e19841521945570e22234e Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Thu, 5 Dec 2024 15:09:15 +0100 Subject: [PATCH 7/7] fix --- dojo/components/sql_group_concat.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dojo/components/sql_group_concat.py b/dojo/components/sql_group_concat.py index 3b08bb4cc5e..6e58b3e2d43 100644 --- a/dojo/components/sql_group_concat.py +++ b/dojo/components/sql_group_concat.py @@ -18,14 +18,6 @@ def __init__( **extra, ) - def as_mysql(self, compiler, connection): - return super().as_sql( - compiler, - connection, - template="%(function)s(%(distinct)s%(expressions)s%(ordering)s%(separator)s)", - separator=f" SEPARATOR '{self.separator}'", - ) - def as_sql(self, compiler, connection, **extra): return super().as_sql( compiler,