@@ -1037,6 +1037,31 @@ def _create_note_if_provided(
10371037 return new_note
10381038
10391039
1040+ def _save_finding_with_jira_sync (finding , * , new_note = None ):
1041+ """
1042+ Persist finding and apply JIRA sync behavior used by finding status actions.
1043+ """
1044+ push_to_jira = False
1045+ finding_in_group = finding .has_finding_group
1046+ jira_issue_exists = finding .has_jira_issue or (
1047+ finding .finding_group and finding .finding_group .has_jira_issue
1048+ )
1049+ jira_instance = jira_helper .get_jira_instance (finding )
1050+ jira_project = jira_helper .get_jira_project (finding )
1051+
1052+ if jira_issue_exists :
1053+ push_to_jira = (
1054+ jira_helper .is_push_all_issues (finding )
1055+ or (jira_instance and jira_instance .finding_jira_sync )
1056+ )
1057+ if new_note and (getattr (jira_project , "push_notes" , False ) or push_to_jira ) and not finding_in_group :
1058+ jira_helper .add_comment (finding , new_note , force_push = True )
1059+
1060+ finding .save (push_to_jira = (push_to_jira and not finding_in_group ))
1061+ if push_to_jira and finding_in_group :
1062+ jira_helper .push_to_jira (finding .finding_group )
1063+
1064+
10401065def close_finding (
10411066 * ,
10421067 finding ,
@@ -1098,26 +1123,7 @@ def close_finding(
10981123 # External issues (best effort)
10991124 close_external_issue (finding .id , "Closed by defectdojo" , "github" )
11001125
1101- # JIRA sync
1102- push_to_jira = False
1103- finding_in_group = finding .has_finding_group
1104- jira_issue_exists = finding .has_jira_issue or (
1105- finding .finding_group and finding .finding_group .has_jira_issue
1106- )
1107- jira_instance = jira_helper .get_jira_instance (finding )
1108- jira_project = jira_helper .get_jira_project (finding )
1109- if jira_issue_exists :
1110- push_to_jira = (
1111- jira_helper .is_push_all_issues (finding )
1112- or (jira_instance and jira_instance .finding_jira_sync )
1113- )
1114- if new_note and (getattr (jira_project , "push_notes" , False ) or push_to_jira ) and not finding_in_group :
1115- jira_helper .add_comment (finding , new_note , force_push = True )
1116-
1117- # Persist and push JIRA if applicable
1118- finding .save (push_to_jira = (push_to_jira and not finding_in_group ))
1119- if push_to_jira and finding_in_group :
1120- jira_helper .push_to_jira (finding .finding_group )
1126+ _save_finding_with_jira_sync (finding , new_note = new_note )
11211127
11221128 # Notification
11231129 create_notification (
@@ -1144,11 +1150,11 @@ def verify_finding(
11441150 finding .last_reviewed_by = user
11451151 finding .last_status_update = verification_time
11461152
1147- _create_note_if_provided (
1153+ new_note = _create_note_if_provided (
11481154 finding ,
11491155 note_entry ,
11501156 note_type = note_type ,
11511157 note_date = verification_time ,
11521158 )
11531159
1154- finding . save ( push_to_jira = False )
1160+ _save_finding_with_jira_sync ( finding , new_note = new_note )
0 commit comments