Skip to content

Commit fd5b2fb

Browse files
jira_integration: changes risk acceptance expiration date to a better default (#13488)
* jira_integration: changes risk acceptance expiration date to a better default * Update dojo/models.py * Update dojo/models.py --------- Co-authored-by: valentijnscholten <valentijnscholten@gmail.com>
1 parent 70145d6 commit fd5b2fb

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.13 on 2025-10-21 10:25
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('dojo', '0244_pghistory_indices'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='jira_instance',
15+
name='accepted_mapping_resolution',
16+
field=models.CharField(blank=True, help_text='JIRA issues that are closed in JIRA with one of these resolutions will result in the Finding becoming Risk Accepted in Defect Dojo. JIRA issues that are closed in JIRA with one of these resolutions will result in the Finding becoming Risk Accepted in Defect Dojo. The expiration time for this Risk Acceptance will be determined by the "Risk acceptance form default days" in "System Settings". This mapping is not used when Findings are pushed to JIRA. In that case the Risk Accepted Findings are closed in JIRA and JIRA sets the default resolution.', max_length=300, null=True, verbose_name='Risk Accepted resolution mapping'),
17+
),
18+
]

dojo/jira_link/helper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any
77

88
import requests
9+
from dateutil.relativedelta import relativedelta
910
from django.conf import settings
1011
from django.contrib import messages
1112
from django.template import TemplateDoesNotExist
@@ -1802,9 +1803,14 @@ def process_resolution_from_jira(finding, resolution_id, resolution_name, assign
18021803

18031804
if finding.test.engagement.product.enable_full_risk_acceptance:
18041805
logger.debug(f"Creating risk acceptance for finding linked to {jira_issue.jira_key}.")
1806+
# loads the expiration from the system setting "Risk acceptance form default days" as otherwise
1807+
# the acceptance will never expire
1808+
risk_acceptance_form_default_days = get_system_setting("risk_acceptance_form_default_days", 90)
1809+
expiration_date_from_system_settings = timezone.now() + relativedelta(days=risk_acceptance_form_default_days)
18051810
ra = Risk_Acceptance.objects.create(
18061811
accepted_by=assignee_name,
18071812
owner=finding.reporter,
1813+
expiration_date=expiration_date_from_system_settings,
18081814
decision_details=f"Risk Acceptance automatically created from JIRA issue {jira_issue.jira_key} with resolution {resolution_name}",
18091815
)
18101816
finding.test.engagement.risk_acceptance.add(ra)

dojo/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3962,7 +3962,7 @@ class JIRA_Instance(models.Model):
39623962
high_mapping_severity = models.CharField(max_length=200, help_text=_("Maps to the 'Priority' field in Jira. For example: High"))
39633963
critical_mapping_severity = models.CharField(max_length=200, help_text=_("Maps to the 'Priority' field in Jira. For example: Critical"))
39643964
finding_text = models.TextField(null=True, blank=True, help_text=_("Additional text that will be added to the finding in Jira. For example including how the finding was created or who to contact for more information."))
3965-
accepted_mapping_resolution = models.CharField(null=True, blank=True, max_length=300, verbose_name="Risk Accepted resolution mapping", help_text=_("JIRA issues that are closed in JIRA with one of these resolutions will result in the Finding becoming Risk Accepted in Defect Dojo. This Risk Acceptance will not have an expiration date. This mapping is not used when Findings are pushed to JIRA. In that case the Risk Accepted Findings are closed in JIRA and JIRA sets the default resolution."))
3965+
accepted_mapping_resolution = models.CharField(null=True, blank=True, max_length=300, verbose_name="Risk Accepted resolution mapping", help_text=_('JIRA issues that are closed in JIRA with one of these resolutions will result in the Finding becoming Risk Accepted in Defect Dojo. JIRA issues that are closed in JIRA with one of these resolutions will result in the Finding becoming Risk Accepted in Defect Dojo. The expiration time for this Risk Acceptance will be determined by the "Risk acceptance form default days" in "System Settings". This mapping is not used when Findings are pushed to JIRA. In that case the Risk Accepted Findings are closed in JIRA and JIRA sets the default resolution.'))
39663966
false_positive_mapping_resolution = models.CharField(null=True, blank=True, verbose_name="False Positive resolution mapping", max_length=300, help_text=_("JIRA issues that are closed in JIRA with one of these resolutions will result in the Finding being marked as False Positive Defect Dojo. This mapping is not used when Findings are pushed to JIRA. In that case the Finding is closed in JIRA and JIRA sets the default resolution."))
39673967
global_jira_sla_notification = models.BooleanField(default=True, blank=False, verbose_name=_("Globally send SLA notifications as comment?"), help_text=_("This setting can be overidden at the Product level"))
39683968
finding_jira_sync = models.BooleanField(default=False, blank=False, verbose_name=_("Automatically sync Findings with JIRA?"), help_text=_("If enabled, this will sync changes to a Finding automatically to JIRA"))

0 commit comments

Comments
 (0)