Skip to content

Commit 97be31b

Browse files
committed
Improve validation
1 parent 30bd9e7 commit 97be31b

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

dojo/db_migrations/0232_set_risk_acceptance_engagement.py renamed to dojo/db_migrations/0245_set_risk_acceptance_engagement.py

File renamed without changes.

dojo/db_migrations/0233_alter_risk_acceptance_engagement.py renamed to dojo/db_migrations/0246_alter_risk_acceptance_engagement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Migration(migrations.Migration):
88

99
dependencies = [
10-
('dojo', '0232_set_risk_acceptance_engagement'),
10+
('dojo', '0245_set_risk_acceptance_engagement'),
1111
]
1212

1313
operations = [

dojo/models.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,13 +3767,15 @@ def __str__(self):
37673767

37683768
def clean(self):
37693769
super().clean()
3770+
from dojo.risk_acceptance.helper import validate_findings_engagement
37703771
if self.pk:
3771-
# Get all findings that do NOT belong to this engagement
3772-
problematic_findings = self.accepted_findings.exclude(test__engagement=self.engagement)
3773-
if problematic_findings.exists():
3774-
problematic_ids = list(problematic_findings.values_list("id", flat=True))
3775-
msg = f"Findings with IDs {problematic_ids} do not belong to engagement {self.engagement_id}."
3776-
raise ValidationError(msg)
3772+
validate_findings_engagement(self.engagement, self.accepted_findings.all())
3773+
# # Get all findings that do NOT belong to this engagement
3774+
# problematic_findings = self.accepted_findings.exclude(test__engagement=self.engagement)
3775+
# if problematic_findings.exists():
3776+
# problematic_ids = list(problematic_findings.values_list("id", flat=True))
3777+
# msg = f"Findings with IDs {problematic_ids} do not belong to engagement {self.engagement_id}."
3778+
# raise ValidationError(msg)
37773779

37783780
def filename(self):
37793781
# logger.debug('path: "%s"', self.path)
@@ -3788,8 +3790,7 @@ def name_and_expiration_info(self):
37883790
def get_breadcrumbs(self):
37893791
bc = self.engagement.get_breadcrumbs()
37903792
bc += [{"title": str(self),
3791-
"url": reverse("view_risk_acceptance", args=(
3792-
self.engagement.product.id, self.id))}]
3793+
"url": reverse("view_risk_acceptance", args=(self.id, ))}]
37933794
return bc
37943795

37953796
@property

0 commit comments

Comments
 (0)