You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add finding group support to jira_status_reconciliation command (#14267)
* Add finding group support to jira_status_reconciliation command
The jira_status_reconciliation management command only processed
individual findings with direct JIRA issues. Finding groups that
were pushed to JIRA as groups were completely skipped because their
JIRA issue is attached to the Finding_Group model, not to individual
findings.
This adds a second processing loop for Finding_Group objects with
JIRA issues, supporting all three modes (reconcile, push_status_to_jira,
import_status_from_jira). The group's aggregate status is derived from
its member findings. To avoid pushing the same JIRA issue twice, we use
push_status_to_jira directly on the group object (not
push_finding_group_to_jira which would also push individual finding
JIRA issues already handled by the existing loop).
Also adds --include-findings/--no-include-findings and
--include-finding-groups/--no-include-finding-groups flags so users
can control which types are processed.
Closes#14031
* add upgrade notes
message=f"{finding_group.jira_issue.jira_key}; {group_url};finding_group:{finding_group.id};{finding_group.status()};skipping finding group with no last_status_update;skipped"
message=f"{finding_group.jira_issue.jira_key}; {group_url};finding_group:{finding_group.id};{finding_group.status()};{resolution_name};no action both sides are active/open;equal"
289
+
messages.append(message)
290
+
logger.info(message)
291
+
elifnotjira_is_activeandnotgroup_is_active:
292
+
message=f"{finding_group.jira_issue.jira_key}; {group_url};finding_group:{finding_group.id};{finding_group.status()};{resolution_name};no action both sides are inactive/closed;equal"
message=f"{finding_group.jira_issue.jira_key}; {group_url};finding_group:{finding_group.id};{finding_group.status()};{resolution_name};{flag1};{flag2};{flag3};{message_action} jira issue for finding group;{status_changed}"
363
+
else:
364
+
ifstatus_changedisNone:
365
+
status_changed="Error"
366
+
message=f"{finding_group.jira_issue.jira_key}; {group_url};finding_group:{finding_group.id};{finding_group.status()};{resolution_name};{flag1};{flag2};{flag3};no changes made while pushing status to jira;{status_changed}"
367
+
368
+
messages.append(message)
369
+
logger.info(message)
370
+
else:
371
+
message=f"{finding_group.jira_issue.jira_key}; {group_url};finding_group:{finding_group.id};{finding_group.status()};{resolution_name};{flag1};{flag2};{flag3};unable to determine source of truth;unknown"
372
+
messages.append(message)
373
+
logger.info(message)
374
+
375
+
376
+
def_max_or_none(iterable):
377
+
"""Return the max of non-None values in iterable, or None if all are None."""
378
+
values= [vforviniterableifvisnotNone]
379
+
returnmax(values) ifvalueselseNone
189
380
190
381
191
382
classCommand(BaseCommand):
@@ -200,21 +391,29 @@ class Command(BaseCommand):
200
391
- sync_from_jira: overwrite status in Defect Dojo with status from JIRA
201
392
"""
202
393
203
-
help="Reconcile finding status with JIRA issue status, stdout will contain semicolon seperated CSV results. \
394
+
help="Reconcile finding/finding group status with JIRA issue status, stdout will contain semicolon seperated CSV results. \
204
395
Risk Accepted findings are skipped. Findings created before 1.14.0 are skipped."
205
396
206
397
mode_help= (
207
398
"- reconcile: (default)reconcile any differences in status between Defect Dojo and JIRA, will look at the latest status change timestamp in both systems to determine which one is the correct status"
208
-
"- push_status_to_jira: update JIRA status for all JIRA issues connected to a Defect Dojo finding (will not push summary/description, only status)"
209
-
"- import_status_from_jira: update Defect Dojo finding status from JIRA"
399
+
"- push_status_to_jira: update JIRA status for all JIRA issues connected to a Defect Dojo finding or finding group (will not push summary/description, only status)"
400
+
"- import_status_from_jira: update Defect Dojo finding/finding group status from JIRA"
0 commit comments