Skip to content

Commit 39338d1

Browse files
author
Valentijn Scholten
committed
finalize return statement
1 parent 2230a03 commit 39338d1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

dojo/finding/deduplication.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,22 @@ def _dedupe_batch_legacy(findings):
529529

530530
def dedupe_batch_of_findings(findings, *args, **kwargs):
531531
"""Batch deduplicate a list of findings. The findings are assumed to be in the same test."""
532+
533+
# Pro has customer implementation which will call the Pro dedupe methods, but also the normal OS dedupe methods.
534+
from dojo.utils import get_custom_method # noqa: PLC0415 -- circular import
535+
if batch_dedupe_method := get_custom_method("FINDING_DEDUPE_BATCH_METHOD"):
536+
deduplicationLogger.debug(f"Using custom deduplication method: {batch_dedupe_method.__name__}")
537+
return batch_dedupe_method(findings, *args, **kwargs)
538+
532539
if not findings:
533-
return
540+
return None
534541

535542
enabled = System_Settings.objects.get().enable_deduplication
536543

537544
if enabled:
538545
# sort findings by id to ensure deduplication is deterministic/reproducible
539546
findings = sorted(findings, key=attrgetter("id"))
540547

541-
from dojo.utils import get_custom_method # noqa: PLC0415 -- circular import
542-
if batch_dedupe_method := get_custom_method("FINDING_DEDUPE_BATCH_METHOD"):
543-
batch_dedupe_method(findings, *args, **kwargs)
544-
545548
test = findings[0].test
546549
dedup_alg = test.deduplication_algorithm
547550

@@ -559,3 +562,4 @@ def dedupe_batch_of_findings(findings, *args, **kwargs):
559562
_dedupe_batch_legacy(findings)
560563
else:
561564
deduplicationLogger.debug("dedupe: skipping dedupe because it's disabled in system settings get()")
565+
return None

dojo/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,7 @@ def deduplication_algorithm(self):
22342234

22352235
@property
22362236
def hash_code_fields(self):
2237+
"""Retrieve OS HASH_CODE_FIELDS_PER_SCANNER settings. Be aware when calling this to make sure Pro doesn't use these OS seetings"""
22372238
hashCodeFields = None
22382239

22392240
if hasattr(settings, "HASHCODE_FIELDS_PER_SCANNER"):
@@ -2916,7 +2917,7 @@ def compute_hash_code(self):
29162917
# Allow Pro to overwrite compute hash_code which gets dedupe settings from a database instead of django.settings
29172918
from dojo.utils import get_custom_method # noqa: PLC0415 circular import
29182919
if compute_hash_code_method := get_custom_method("FINDING_COMPUTE_HASH_METHOD"):
2919-
deduplicationLogger.debug("using custom compute_hash_code method")
2920+
deduplicationLogger.debug("using custom FINDING_COMPUTE_HASH_METHOD method")
29202921
return compute_hash_code_method(self)
29212922

29222923
# Check if all needed settings are defined

0 commit comments

Comments
 (0)