Skip to content

Commit ed83097

Browse files
valentijnscholtenValentijn Scholten
andauthored
reimport: support pro hash method (#13680)
Co-authored-by: Valentijn Scholten <[email protected]>
1 parent 2171863 commit ed83097

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

dojo/importers/default_reimporter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,4 +772,6 @@ def calculate_unsaved_finding_hash_code(
772772
self,
773773
unsaved_finding: Finding,
774774
) -> str:
775+
# this is overridden in Pro, but will still call this via super()
776+
deduplicationLogger.debug("Calculating hash code for unsaved finding")
775777
return unsaved_finding.compute_hash_code()

dojo/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,6 +2908,11 @@ def risk_acceptance(self):
29082908
return None
29092909

29102910
def compute_hash_code(self):
2911+
# Allow Pro to overwrite compute hash_code which gets dedupe settings from a database instead of django.settings
2912+
from dojo.utils import get_custom_method # noqa: PLC0415 circular import
2913+
if compute_hash_code_method := get_custom_method("FINDING_COMPUTE_HASH_METHOD"):
2914+
deduplicationLogger.debug("using custom compute_hash_code method")
2915+
return compute_hash_code_method(self)
29112916

29122917
# Check if all needed settings are defined
29132918
if not hasattr(settings, "HASHCODE_FIELDS_PER_SCANNER") or not hasattr(settings, "HASHCODE_ALLOWS_NULL_CWE") or not hasattr(settings, "HASHCODE_ALLOWED_FIELDS"):

0 commit comments

Comments
 (0)