Skip to content

Commit 2bc529d

Browse files
authored
Jira Webhook: Prevent finding group findings from being reopened (#12048)
* Jira Webhook: Prevent finding group findings from being reopened * Fix ruff
1 parent 28089fc commit 2bc529d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

dojo/jira_link/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ def escape_for_jira(text):
16771677
return text.replace("|", "%7D")
16781678

16791679

1680-
def process_resolution_from_jira(finding, resolution_id, resolution_name, assignee_name, jira_now, jira_issue) -> bool:
1680+
def process_resolution_from_jira(finding, resolution_id, resolution_name, assignee_name, jira_now, jira_issue, finding_group: Finding_Group = None) -> bool:
16811681
"""Processes the resolution field in the JIRA issue and updated the finding in Defect Dojo accordingly"""
16821682
import dojo.risk_acceptance.helper as ra_helper
16831683
status_changed = False
@@ -1720,7 +1720,7 @@ def process_resolution_from_jira(finding, resolution_id, resolution_name, assign
17201720
finding.false_p = False
17211721
ra_helper.risk_unaccept(User.objects.get_or_create(username="JIRA")[0], finding)
17221722
status_changed = True
1723-
elif not finding.active:
1723+
elif not finding.active and (finding_group is None or settings.JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN):
17241724
# Reopen / Open Jira issue
17251725
logger.debug(f"Re-opening related finding of {jira_issue.jira_key}")
17261726
finding.active = True

dojo/jira_link/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def webhook(request, secret=None):
137137

138138
if findings:
139139
for finding in findings:
140-
jira_helper.process_resolution_from_jira(finding, resolution_id, resolution_name, assignee_name, jira_now, jissue)
140+
jira_helper.process_resolution_from_jira(finding, resolution_id, resolution_name, assignee_name, jira_now, jissue, finding_group=jissue.finding_group)
141141
# Check for any comment that could have come along with the resolution
142142
if (error_response := check_for_and_create_comment(parsed)) is not None:
143143
return error_response

dojo/settings/settings.dist.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@
225225
DD_MAX_REQRESP_FROM_API=(int, -1),
226226
DD_MAX_AUTOCOMPLETE_WORDS=(int, 20000),
227227
DD_JIRA_SSL_VERIFY=(bool, True),
228+
# When interacting with jira tickets that attached finding groups, we should no be opening any findings
229+
# on the DefectDojo side because jira has no way of knowing if a finding really should be reopened or not
230+
DD_JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN=(bool, False),
228231
# You can set extra Jira issue types via a simple env var that supports a csv format, like "Work Item,Vulnerability"
229232
DD_JIRA_EXTRA_ISSUE_TYPES=(str, ""),
230233
# if you want to keep logging to the console but in json format, change this here to 'json_console'
@@ -1632,6 +1635,7 @@ def saml2_attrib_map_format(din):
16321635
JIRA_ISSUE_TYPE_CHOICES_CONFIG += ((extra_type, extra_type),)
16331636

16341637
JIRA_SSL_VERIFY = env("DD_JIRA_SSL_VERIFY")
1638+
JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN = env("DD_JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN")
16351639

16361640
# ------------------------------------------------------------------------------
16371641
# LOGGING

0 commit comments

Comments
 (0)