Skip to content

Commit a6b411a

Browse files
Remove non-working DD_SLA_BUSINESS_DAYS feature to avoid confusion (#12131)
* Remove DD_SLA_BUSINESS_DAYS feature * change target release to 2.46.0 * change target release to 2.46.0
1 parent 04ebea4 commit a6b411a

File tree

5 files changed

+36
-86
lines changed

5 files changed

+36
-86
lines changed

docs/content/en/open_source/upgrading/2.46.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ weight: -20250407
55
description: Tag Formatting Changes + Import Payload Changes
66
---
77

8-
### Tag Formatting Update
8+
9+
## Tag Formatting Update
910

1011
Tags can no longer contain the following characters:
1112

@@ -38,6 +39,13 @@ We recommend reviewing your current tags, specifically CI/CD processes before up
3839

3940
Following the deployment of these new behaviors, requests sent to the API or through the UI with any of the violations listed above will result in an error, with the details of the error raised in the response.
4041

42+
43+
## Feature Removal
44+
The `DD_SLA_BUSINESS_DAYS` flag was no longer working and has been removed to avoid confusion.
45+
If it returns, it will probably be part of the SLA Configuration settings in the UI.
46+
There are currently no plans to reimplemnt this feature.
47+
Please follow [11833](https://github.com/DefectDojo/django-DefectDojo/issues/11833) for updates.
48+
4149
---
4250

4351
### Asynchronous Import Feature Removal in 2.47.0
@@ -79,3 +87,4 @@ After:
7987
---
8088

8189
Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.46.0) for the contents of the release.
90+

dojo/db_migrations/0201_populate_finding_sla_expiration_date.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from dateutil.relativedelta import relativedelta
66
import logging
77

8-
from dojo.utils import get_work_days
9-
108
logger = logging.getLogger(__name__)
119

1210

@@ -44,19 +42,13 @@ def calculate_sla_expiration_dates(apps, schema_editor):
4442
sla_period = getattr(sla_config, find.severity.lower(), None)
4543

4644
days = None
47-
if settings.SLA_BUSINESS_DAYS:
48-
if find.mitigated:
49-
days = get_work_days(find.date, find.mitigated.date())
50-
else:
51-
days = get_work_days(find.date, timezone.now().date())
52-
else:
53-
if isinstance(start_date, datetime):
54-
start_date = start_date.date()
45+
if isinstance(start_date, datetime):
46+
start_date = start_date.date()
5547

56-
if find.mitigated:
57-
days = (find.mitigated.date() - start_date).days
58-
else:
59-
days = (timezone.now().date() - start_date).days
48+
if find.mitigated:
49+
days = (find.mitigated.date() - start_date).days
50+
else:
51+
days = (timezone.now().date() - start_date).days
6052

6153
days = days if days > 0 else 0
6254

dojo/models.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,27 +3007,17 @@ def _age(self, start_date):
30073007
if start_date and isinstance(start_date, str):
30083008
start_date = parse(start_date).date()
30093009

3010-
from dojo.utils import get_work_days
3011-
if settings.SLA_BUSINESS_DAYS:
3012-
if self.mitigated:
3013-
mitigated_date = self.mitigated
3014-
if isinstance(mitigated_date, datetime):
3015-
mitigated_date = self.mitigated.date()
3016-
days = get_work_days(self.date, mitigated_date)
3017-
else:
3018-
days = get_work_days(self.date, get_current_date())
3010+
if isinstance(start_date, datetime):
3011+
start_date = start_date.date()
3012+
3013+
if self.mitigated:
3014+
mitigated_date = self.mitigated
3015+
if isinstance(mitigated_date, datetime):
3016+
mitigated_date = self.mitigated.date()
3017+
diff = mitigated_date - start_date
30193018
else:
3020-
if isinstance(start_date, datetime):
3021-
start_date = start_date.date()
3022-
3023-
if self.mitigated:
3024-
mitigated_date = self.mitigated
3025-
if isinstance(mitigated_date, datetime):
3026-
mitigated_date = self.mitigated.date()
3027-
diff = mitigated_date - start_date
3028-
else:
3029-
diff = get_current_date() - start_date
3030-
days = diff.days
3019+
diff = get_current_date() - start_date
3020+
days = diff.days
30313021
return max(0, days)
30323022

30333023
@property

dojo/settings/settings.dist.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@
217217
# finetuning settings for when enabled
218218
DD_SLA_NOTIFY_PRE_BREACH=(int, 3),
219219
DD_SLA_NOTIFY_POST_BREACH=(int, 7),
220-
# Use business day's to calculate SLA's and age instead of calendar days
221-
DD_SLA_BUSINESS_DAYS=(bool, False),
222220
# maximum number of result in search as search can be an expensive operation
223221
DD_SEARCH_MAX_RESULTS=(int, 100),
224222
DD_SIMILAR_FINDINGS_MAX_RESULTS=(int, 25),
@@ -654,7 +652,6 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
654652
SLA_NOTIFY_WITH_JIRA_ONLY = env("DD_SLA_NOTIFY_WITH_JIRA_ONLY") # Based on the 2 above, but only with a JIRA link
655653
SLA_NOTIFY_PRE_BREACH = env("DD_SLA_NOTIFY_PRE_BREACH") # in days, notify between dayofbreach minus this number until dayofbreach
656654
SLA_NOTIFY_POST_BREACH = env("DD_SLA_NOTIFY_POST_BREACH") # in days, skip notifications for findings that go past dayofbreach plus this number
657-
SLA_BUSINESS_DAYS = env("DD_SLA_BUSINESS_DAYS") # Use business days to calculate SLA's and age of a finding instead of calendar days
658655

659656

660657
SEARCH_MAX_RESULTS = env("DD_SEARCH_MAX_RESULTS")

dojo/utils.py

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,35 +1624,6 @@ def get_celery_worker_status():
16241624
return False
16251625

16261626

1627-
def get_work_days(start: date, end: date):
1628-
"""
1629-
Math function to get workdays between 2 dates.
1630-
Can be used only as fallback as it doesn't know
1631-
about specific country holidays or extra working days.
1632-
https://stackoverflow.com/questions/3615375/number-of-days-between-2-dates-excluding-weekends/71977946#71977946
1633-
"""
1634-
# if the start date is on a weekend, forward the date to next Monday
1635-
if start.weekday() > WEEKDAY_FRIDAY:
1636-
start += timedelta(days=7 - start.weekday())
1637-
1638-
# if the end date is on a weekend, rewind the date to the previous Friday
1639-
if end.weekday() > WEEKDAY_FRIDAY:
1640-
end -= timedelta(days=end.weekday() - WEEKDAY_FRIDAY)
1641-
1642-
if start > end:
1643-
return 0
1644-
# that makes the difference easy, no remainders etc
1645-
diff_days = (end - start).days + 1
1646-
weeks = int(diff_days / 7)
1647-
1648-
remainder = end.weekday() - start.weekday() + 1
1649-
1650-
if remainder != 0 and end.weekday() < start.weekday():
1651-
remainder += 5
1652-
1653-
return weeks * 5 + remainder
1654-
1655-
16561627
# Used to display the counts and enabled tabs in the product view
16571628
class Product_Tab:
16581629
def __init__(self, product, title=None, tab=None):
@@ -2479,26 +2450,17 @@ def calculate_finding_age(f):
24792450
if start_date and isinstance(start_date, str):
24802451
start_date = parse(start_date).date()
24812452

2482-
if settings.SLA_BUSINESS_DAYS:
2483-
if f.get("mitigated"):
2484-
mitigated_date = f.get("mitigated")
2485-
if isinstance(mitigated_date, datetime):
2486-
mitigated_date = f.get("mitigated").date()
2487-
days = get_work_days(f.get("date"), mitigated_date)
2488-
else:
2489-
days = get_work_days(f.get("date"), timezone.now().date())
2453+
if isinstance(start_date, datetime):
2454+
start_date = start_date.date()
2455+
2456+
if f.get("mitigated"):
2457+
mitigated_date = f.get("mitigated")
2458+
if isinstance(mitigated_date, datetime):
2459+
mitigated_date = f.get("mitigated").date()
2460+
diff = mitigated_date - start_date
24902461
else:
2491-
if isinstance(start_date, datetime):
2492-
start_date = start_date.date()
2493-
2494-
if f.get("mitigated"):
2495-
mitigated_date = f.get("mitigated")
2496-
if isinstance(mitigated_date, datetime):
2497-
mitigated_date = f.get("mitigated").date()
2498-
diff = mitigated_date - start_date
2499-
else:
2500-
diff = timezone.now().date() - start_date
2501-
days = diff.days
2462+
diff = timezone.now().date() - start_date
2463+
days = diff.days
25022464
return max(0, days)
25032465

25042466

0 commit comments

Comments
 (0)