@@ -109,6 +109,14 @@ def is_push_all_issues(instance):
109109 return None
110110
111111
112+ def _safely_get_finding_group_status (finding_group : Finding_Group ) -> str :
113+ # Accommodating a strange behavior where a finding group sometimes prefers `obj.status` rather than `obj.status()`
114+ try :
115+ return finding_group .status ()
116+ except TypeError : # TypeError: 'str' object is not callable
117+ return finding_group .status
118+
119+
112120# checks if a finding can be pushed to JIRA
113121# optionally provides a form with the new data for the finding
114122# any finding that already has a JIRA issue can be pushed again to JIRA
@@ -161,13 +169,8 @@ def can_be_pushed_to_jira(obj, form=None):
161169 elif isinstance (obj , Finding_Group ):
162170 if not obj .findings .all ():
163171 return False , f"{ to_str_typed (obj )} cannot be pushed to jira as it is empty." , "error_empty"
164- # Accommodating a strange behavior where a finding group sometimes prefers `obj.status` rather than `obj.status()`
165- try :
166- not_active = "Active" not in obj .status ()
167- except TypeError : # TypeError: 'str' object is not callable
168- not_active = "Active" not in obj .status
169172 # Determine if the finding group is not active
170- if not_active :
173+ if "Active" not in _safely_get_finding_group_status ( obj ) :
171174 return False , f"{ to_str_typed (obj )} cannot be pushed to jira as it is not active." , "error_inactive"
172175
173176 else :
@@ -1101,7 +1104,7 @@ def issue_from_jira_is_active(issue_from_jira):
11011104
11021105
11031106def push_status_to_jira (obj , jira_instance , jira , issue , * , save = False ):
1104- status_list = obj . status ( )
1107+ status_list = _safely_get_finding_group_status ( obj )
11051108 issue_closed = False
11061109 # check RESOLVED_STATUS first to avoid corner cases with findings that are Inactive, but verified
11071110 if any (item in status_list for item in RESOLVED_STATUS ):
@@ -1740,20 +1743,19 @@ def process_resolution_from_jira(finding, resolution_id, resolution_name, assign
17401743
17411744def save_and_push_to_jira (finding ):
17421745 # Manage the jira status changes
1743- push_to_jira = False
1746+ push_to_jira_decision = False
17441747 # Determine if the finding is in a group. if so, not push to jira yet
17451748 finding_in_group = finding .has_finding_group
17461749 # Check if there is a jira issue that needs to be updated
17471750 jira_issue_exists = finding .has_jira_issue or (finding .finding_group and finding .finding_group .has_jira_issue )
17481751 # Only push if the finding is not in a group
17491752 if jira_issue_exists :
17501753 # Determine if any automatic sync should occur
1751- push_to_jira = is_push_all_issues (finding ) \
1754+ push_to_jira_decision = is_push_all_issues (finding ) \
17521755 or get_jira_instance (finding ).finding_jira_sync
17531756 # Save the finding
1754- finding .save (push_to_jira = (push_to_jira and not finding_in_group ))
1755-
1757+ finding .save (push_to_jira = (push_to_jira_decision and not finding_in_group ))
17561758 # we only push the group after saving the finding to make sure
17571759 # the updated data of the finding is pushed as part of the group
1758- if push_to_jira and finding_in_group :
1760+ if push_to_jira_decision and finding_in_group :
17591761 push_to_jira (finding .finding_group )
0 commit comments