Skip to content

Commit e431393

Browse files
authored
Merge pull request #13801 from DefectDojo/bugfix
Release 2.53.0: Merge Bugfix into Dev
2 parents 29000e0 + 3093590 commit e431393

4 files changed

Lines changed: 57 additions & 4 deletions

File tree

.github/workflows/test-helm-chart.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ jobs:
114114
- name: Update values in HELM chart
115115
if: startsWith(github.head_ref, 'renovate/') || startsWith(github.head_ref, 'dependabot/')
116116
run: |
117-
yq -i '.annotations."artifacthub.io/changes" += "- kind: changed\n description: ${{ github.event.pull_request.title }}\n"' helm/defectdojo/Chart.yaml
117+
title=${{ github.event.pull_request.title }}
118+
chars='{}:[],&*#?|-<>=!%@'
119+
for c in $(echo "$chars" | grep -o .); do
120+
title="${title//"$c"/_}"
121+
done
122+
yq -i '.annotations."artifacthub.io/changes" += "- kind: changed\n description: $title\n"' helm/defectdojo/Chart.yaml
118123
git add helm/defectdojo/Chart.yaml
119124
git commit -m "ci: update Chart annotations from PR #${{ github.event.pull_request.number }}" || echo "No changes to commit"
120125

docs/content/en/share_your_findings/troubleshooting_jira.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,34 @@ To correct this issue, you can add the 'Epic Name' field to your Project's issue
101101

102102
![image](images/epic_name_error.png)
103103

104+
## Configuring JIRA Connection Retries and Timeouts
105+
106+
DefectDojo's JIRA integration includes configurable retry and timeout settings to handle rate limiting and connection issues. These settings are important for maintaining system responsiveness, especially when using Celery workers.
107+
108+
### Available Configuration Variables
109+
110+
The following environment variables control JIRA connection behavior:
111+
112+
- **`DD_JIRA_MAX_RETRIES`** (default: `3`): Maximum number of retry attempts for recoverable errors. The integration will automatically retry on HTTP 429 (Too Many Requests), HTTP 503 (Service Unavailable), and connection errors. See the [JIRA rate limiting documentation](https://developer.atlassian.com/cloud/jira/platform/rate-limiting/) for more information.
113+
114+
- **`DD_JIRA_CONNECT_TIMEOUT`** (default: `10` seconds): Connection timeout for establishing a connection to the JIRA server.
115+
116+
- **`DD_JIRA_READ_TIMEOUT`** (default: `30` seconds): Read timeout for waiting for a response from the JIRA server after the connection is established.
117+
118+
**Note on Rate Limiting**: The jira library has a built-in maximum wait time of 60 seconds for rate limiting retries. If JIRA's `Retry-After` header indicates a wait time longer than 60 seconds, the request will fail and not be retried. This is a limitation of the jira library version currently in use.
119+
120+
### Why Conservative Values Matter
121+
122+
**Important**: It is recommended to use conservative (lower) values for these settings. Here's why:
123+
124+
1. **Celery Task Blocking**: JIRA operations in DefectDojo run as asynchronous Celery tasks. When a task is waiting for a retry delay, it blocks that Celery worker from processing other tasks.
125+
126+
2. **Worker Pool Exhaustion**: If multiple JIRA operations are retrying with long delays, you can quickly exhaust your Celery worker pool, causing other tasks (not just JIRA-related) to queue up and wait.
127+
128+
3. **System Responsiveness**: Long retry delays can make the system appear unresponsive, especially during JIRA outages or rate limiting events.
129+
130+
JIRA Rate limiting is new, so please let us know on Slack or GitHub what works best for you.
131+
104132
## Jira and DefectDojo are out of sync
105133

106134
Sometimes Jira is down, or DefectDojo is down, or there was bug in a webhook. In this case, Jira can become out of sync with DefectDojo. If this is the case for lots of issues, manual reconciliation might not be feasible. For this scenario there is the management command 'jira_status_reconciliation'.

dojo/jira_link/helper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def can_be_pushed_to_jira(obj, form=None):
208208
return False, f"Finding below the minimum JIRA severity threshold ({System_Settings.objects.get().jira_minimum_severity}).", "error_below_minimum_threshold"
209209
elif isinstance(obj, Finding_Group):
210210
finding_group_status = _safely_get_obj_status_for_jira(obj)
211-
logger.error("Finding group status: %s", finding_group_status)
212211
if "Empty" in finding_group_status:
213212
return False, f"{to_str_typed(obj)} cannot be pushed to jira as it contains no findings above minimum treshold.", "error_empty"
214213

@@ -433,14 +432,19 @@ def has_jira_configured(obj):
433432

434433

435434
def connect_to_jira(jira_server, jira_username, jira_password):
435+
max_retries = getattr(settings, "JIRA_MAX_RETRIES", 3)
436+
timeout = getattr(settings, "JIRA_TIMEOUT", (10, 30))
437+
436438
return JIRA(
437439
server=jira_server,
438440
basic_auth=(jira_username, jira_password),
439-
max_retries=0,
441+
max_retries=max_retries,
442+
timeout=timeout,
440443
options={
441444
"verify": settings.JIRA_SSL_VERIFY,
442445
"headers": settings.ADDITIONAL_HEADERS,
443-
})
446+
},
447+
)
444448

445449

446450
def get_jira_connect_method():

dojo/settings/settings.dist.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@
250250
# When interacting with jira tickets that attached finding groups, we should no be opening any findings
251251
# on the DefectDojo side because jira has no way of knowing if a finding really should be reopened or not
252252
DD_JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN=(bool, False),
253+
# JIRA connection retry and timeout settings: https://developer.atlassian.com/cloud/jira/platform/rate-limiting/
254+
# Maximum number of retry attempts for recoverable errors (429, 503, ConnectionError)
255+
# See https://jira.readthedocs.io/ for more in the jira library used by DefectDojo
256+
# Note: The jira library has a built-in maximum wait time of 60s for rate limiting retries.
257+
# If JIRA's Retry-After header indicates a wait time longer than 60s, the request will fail and not be retried.
258+
DD_JIRA_MAX_RETRIES=(int, 3),
259+
# Connection timeout (seconds) for establishing a connection to the JIRA server
260+
DD_JIRA_CONNECT_TIMEOUT=(int, 10),
261+
# Read timeout (seconds) for waiting for a response from the JIRA server
262+
DD_JIRA_READ_TIMEOUT=(int, 30),
253263
# You can set extra Jira issue types via a simple env var that supports a csv format, like "Work Item,Vulnerability"
254264
DD_JIRA_EXTRA_ISSUE_TYPES=(str, ""),
255265
# if you want to keep logging to the console but in json format, change this here to 'json_console'
@@ -1723,6 +1733,12 @@ def saml2_attrib_map_format(din):
17231733
JIRA_SSL_VERIFY = env("DD_JIRA_SSL_VERIFY")
17241734
JIRA_DESCRIPTION_MAX_LENGTH = env("DD_JIRA_DESCRIPTION_MAX_LENGTH")
17251735
JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN = env("DD_JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN")
1736+
# JIRA connection retry and timeout settings
1737+
JIRA_MAX_RETRIES = env("DD_JIRA_MAX_RETRIES")
1738+
JIRA_CONNECT_TIMEOUT = env("DD_JIRA_CONNECT_TIMEOUT")
1739+
JIRA_READ_TIMEOUT = env("DD_JIRA_READ_TIMEOUT")
1740+
# Combine timeouts into a tuple for the JIRA library: (connect_timeout, read_timeout)
1741+
JIRA_TIMEOUT = (JIRA_CONNECT_TIMEOUT, JIRA_READ_TIMEOUT)
17261742

17271743
# ------------------------------------------------------------------------------
17281744
# LOGGING

0 commit comments

Comments
 (0)