Skip to content

Commit

Permalink
remove mysql leftover (#10694)
Browse files Browse the repository at this point in the history
* ruff

* ruff

* rebase

* udpate

* fix

* fix

* fix
manuel-sommer authored Jan 23, 2025
1 parent 321d580 commit 5b01bdd
Showing 4 changed files with 2 additions and 27 deletions.
8 changes: 0 additions & 8 deletions dojo/components/sql_group_concat.py
Original file line number Diff line number Diff line change
@@ -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,
15 changes: 1 addition & 14 deletions dojo/metrics/utils.py
Original file line number Diff line number Diff line change
@@ -8,9 +8,7 @@

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.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
@@ -539,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()),
4 changes: 0 additions & 4 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion dojo/settings/template-env
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 5b01bdd

Please sign in to comment.