Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Delete: Race condition bolstering #11549

Open
wants to merge 1 commit into
base: bugfix
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading