@@ -24,19 +24,25 @@ def expire_now(risk_acceptance):
2424 for finding in risk_acceptance .accepted_findings .all ():
2525 if not finding .active : # not sure why this is important
2626 logger .debug ("%i:%s: unaccepting/reactivating finding." , finding .id , finding )
27+ finding .active = True
28+ finding .risk_accepted = False
2729
2830 # Update any endpoint statuses on each of the findings
2931 update_endpoint_statuses (finding , accept_risk = False )
30- risk_unaccept (None , finding , post_comments = False ) # comments will be posted at end
3132
3233 if risk_acceptance .restart_sla_expired :
3334 finding .sla_start_date = timezone .now ().date ()
34- finding .save (dedupe_option = False ) # resave if changed after risk_unaccept
35+ # this method both saves and pushed to JIRA (no other post processing)
36+ finding .save (dedupe_option = False )
37+ if jira_helper .is_push_all_issues (finding ) or jira_helper .is_keep_in_sync_with_jira (finding ):
38+ logger .info ("pushing finding to JIRA after expiration of risk acceptance" )
39+ jira_helper .push_to_jira (finding )
3540
3641 reactivated_findings .append (finding )
3742 else :
3843 logger .debug ("%i:%s already active, no changes made." , finding .id , finding )
3944
45+ # best effort JIRA integration, no status changes, just a comment
4046 post_jira_comments (risk_acceptance , risk_acceptance .accepted_findings .all (), expiration_message_creator )
4147
4248 risk_acceptance .expiration_date = timezone .now ()
@@ -68,12 +74,16 @@ def reinstate(risk_acceptance, old_expiration_date):
6874 finding .risk_accepted = True
6975 # Update any endpoint statuses on each of the findings
7076 update_endpoint_statuses (finding , accept_risk = True )
77+ # this method both saves and pushed to JIRA (no other post processing)
7178 finding .save (dedupe_option = False )
79+ if jira_helper .is_push_all_issues (finding ) or jira_helper .is_keep_in_sync_with_jira (finding ):
80+ logger .info ("pushing finding to JIRA after reinstating risk acceptance" )
81+ jira_helper .push_to_jira (finding )
7282 reinstated_findings .append (finding )
7383 else :
7484 logger .debug ("%i:%s: already inactive, not making any changes" , finding .id , finding )
7585
76- # best effort JIRA integration, no status changes
86+ # best effort JIRA integration, no status changes, just a comment
7787 post_jira_comments (risk_acceptance , risk_acceptance .accepted_findings .all (), reinstation_message_creator )
7888
7989 risk_acceptance .expiration_date_handled = None
@@ -108,7 +118,12 @@ def remove_finding_from_risk_acceptance(user: Dojo_User, risk_acceptance: Risk_A
108118 finding .risk_accepted = False
109119 # Update any endpoint statuses on each of the findings
110120 update_endpoint_statuses (finding , accept_risk = False )
121+ # this method both saves and pushed to JIRA (no other post processing)
111122 finding .save (dedupe_option = False )
123+ if jira_helper .is_push_all_issues (finding ) or jira_helper .is_keep_in_sync_with_jira (finding ):
124+ logger .info ("pushing finding to JIRA after removal from risk acceptance" )
125+ jira_helper .push_to_jira (finding )
126+
112127 # best effort jira integration, no status changes
113128 post_jira_comments (risk_acceptance , [finding ], unaccepted_message_creator )
114129 # Add a note to reflect that the finding was removed from the risk acceptance
@@ -132,7 +147,13 @@ def add_findings_to_risk_acceptance(user: Dojo_User, risk_acceptance: Risk_Accep
132147 finding .save (dedupe_option = False )
133148 # Update any endpoint statuses on each of the findings
134149 update_endpoint_statuses (finding , accept_risk = True )
150+
135151 risk_acceptance .accepted_findings .add (finding )
152+
153+ if jira_helper .is_push_all_issues (finding ) or jira_helper .is_keep_in_sync_with_jira (finding ):
154+ logger .info ("pushing finding to JIRA after adding to risk acceptance" )
155+ jira_helper .push_to_jira (finding )
156+
136157 # Add a note to reflect that the finding was removed from the risk acceptance
137158 if user is not None :
138159 finding .notes .add (Notes .objects .create (
@@ -314,6 +335,9 @@ def simple_risk_accept(user: Dojo_User, finding: Finding, *, perform_save=True)
314335 finding .save (dedupe_option = False )
315336 # post_jira_comment might reload from database so see unaccepted finding. but the comment
316337 # only contains some text so that's ok
338+ if jira_helper .is_push_all_issues (finding ) or jira_helper .is_keep_in_sync_with_jira (finding ):
339+ jira_helper .push_to_jira (finding )
340+
317341 post_jira_comment (finding , accepted_message_creator )
318342 # Add a note to reflect that the finding was removed from the risk acceptance
319343 if user is not None :
@@ -344,7 +368,8 @@ def risk_unaccept(user: Dojo_User, finding: Finding, *, perform_save=True, post_
344368 post_jira_comment (finding , unaccepted_message_creator )
345369
346370 # Update the JIRA obect for this finding
347- jira_helper .save_and_push_to_jira (finding )
371+ if jira_helper .is_push_all_issues (finding ) or jira_helper .is_keep_in_sync_with_jira (finding ):
372+ jira_helper .push_to_jira (finding )
348373
349374 # Add a note to reflect that the finding was removed from the risk acceptance
350375 if user is not None :
0 commit comments