Skip to content

Commit

Permalink
Async Delete: Race condition bolstering
Browse files Browse the repository at this point in the history
  • Loading branch information
Maffooch committed Jan 10, 2025
1 parent 600eccc commit 18560e6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import re
import warnings
from contextlib import suppress
from datetime import datetime
from pathlib import Path
from uuid import uuid4
Expand Down Expand Up @@ -1575,7 +1576,10 @@ def delete(self, *args, **kwargs):
import dojo.finding.helper as helper
helper.prepare_duplicates_for_delete(engagement=self)
super().delete(*args, **kwargs)
calculate_grade(self.product)
with suppress(Product.DoesNotExist):
# Suppressing a potential issue created from async delete removing
# related objects in a separate task
calculate_grade(self.product)

def inherit_tags(self, potentially_existing_tags):
# get a copy of the tags to be inherited
Expand Down Expand Up @@ -2185,7 +2189,10 @@ def hash_code_allows_null_cwe(self):
def delete(self, *args, **kwargs):
logger.debug("%d test delete", self.id)
super().delete(*args, **kwargs)
calculate_grade(self.engagement.product)
with suppress(Engagement.DoesNotExist, Product.DoesNotExist):
# Suppressing a potential issue created from async delete removing
# related objects in a separate task
calculate_grade(self.engagement.product)

@property
def statistics(self):
Expand Down Expand Up @@ -2745,7 +2752,10 @@ def delete(self, *args, **kwargs):
import dojo.finding.helper as helper
helper.finding_delete(self)
super().delete(*args, **kwargs)
calculate_grade(self.test.engagement.product)
with suppress(Test.DoesNotExist, Engagement.DoesNotExist, Product.DoesNotExist):
# Suppressing a potential issue created from async delete removing
# related objects in a separate task
calculate_grade(self.test.engagement.product)

# only used by bulk risk acceptance api
@classmethod
Expand Down

0 comments on commit 18560e6

Please sign in to comment.