Skip to content

Commit d8675fe

Browse files
fix: ui must not overwrite service field from parser (#13517)
* fix: ui must not overwrite service field from parser * docs: add upgrade note
1 parent 0fd62d6 commit d8675fe

6 files changed

Lines changed: 35 additions & 20 deletions

File tree

docs/content/en/open_source/upgrading/2.52.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ weight: -20251006
55
description: MobSF parsers & Helm chart changes.
66
---
77

8+
## Fix UI overwriting service field from parsers
9+
10+
The web form in the UI by default sends an empty string, which ended up overwriting the service value provided by parsers.
11+
12+
Only a few parsers do this, so the impact of this fix is low:
13+
14+
- Trivy Scan
15+
- Trivy Operator Scan
16+
- Hydra Scan
17+
- JFrog Xray API Summary Artifact Scan
18+
- StackHawk HawkScan
19+
20+
See [PR 13517](https://github.com/DefectDojo/django-DefectDojo/pull/13517) for more details.
21+
822
## Deduplication fix of `UNIQUE_ID_OR_HASH_CODE`
923
A bug was fixed in the `UNIQUE_ID_OR_HASH_CODE` algorithm where it stopped processing candidate findings with equal `unique_id_from_tool` or `hash_code` value.
1024
Strictly speaking this is not a breaking change, but we wanted to make you aware that you can see more (better) more deduplicatation for parsers using this algorithm.

dojo/engagement/views.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -962,19 +962,19 @@ def process_form(
962962
"active": None,
963963
"verified": None,
964964
"scan_type": request.POST.get("scan_type"),
965-
"test_title": form.cleaned_data.get("test_title"),
965+
"test_title": form.cleaned_data.get("test_title") or None,
966966
"tags": form.cleaned_data.get("tags"),
967-
"version": form.cleaned_data.get("version"),
968-
"branch_tag": form.cleaned_data.get("branch_tag", None),
969-
"build_id": form.cleaned_data.get("build_id", None),
970-
"commit_hash": form.cleaned_data.get("commit_hash", None),
971-
"api_scan_configuration": form.cleaned_data.get("api_scan_configuration", None),
972-
"service": form.cleaned_data.get("service", None),
967+
"version": form.cleaned_data.get("version") or None,
968+
"branch_tag": form.cleaned_data.get("branch_tag") or None,
969+
"build_id": form.cleaned_data.get("build_id") or None,
970+
"commit_hash": form.cleaned_data.get("commit_hash") or None,
971+
"api_scan_configuration": form.cleaned_data.get("api_scan_configuration") or None,
972+
"service": form.cleaned_data.get("service") or None,
973973
"close_old_findings": form.cleaned_data.get("close_old_findings", None),
974974
"apply_tags_to_findings": form.cleaned_data.get("apply_tags_to_findings", False),
975975
"apply_tags_to_endpoints": form.cleaned_data.get("apply_tags_to_endpoints", False),
976976
"close_old_findings_product_scope": form.cleaned_data.get("close_old_findings_product_scope", None),
977-
"group_by": form.cleaned_data.get("group_by", None),
977+
"group_by": form.cleaned_data.get("group_by") or None,
978978
"create_finding_groups_for_all_findings": form.cleaned_data.get("create_finding_groups_for_all_findings", None),
979979
"environment": self.get_development_environment(environment_name=form.cleaned_data.get("environment")),
980980
})

dojo/importers/default_reimporter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ def process_findings(
170170
# we need to make sure there are no side effects such as closing findings
171171
# for findings with a different service value
172172
# https://github.com/DefectDojo/django-DefectDojo/issues/12754
173-
original_findings = self.test.finding_set.all().filter(service=self.service)
173+
if self.service is not None:
174+
original_findings = self.test.finding_set.all().filter(service=self.service)
175+
else:
176+
original_findings = self.test.finding_set.all().filter(Q(service__isnull=True) | Q(service__exact=""))
177+
174178
logger.debug(f"original_findings_qyer: {original_findings.query}")
175179
self.original_items = list(original_findings)
176180
logger.debug(f"original_items: {[(item.id, item.hash_code) for item in self.original_items]}")

dojo/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,7 @@ def hash_fields(self, fields_to_hash):
30103010
if hasattr(settings, "HASH_CODE_FIELDS_ALWAYS"):
30113011
for field in settings.HASH_CODE_FIELDS_ALWAYS:
30123012
if getattr(self, field):
3013+
deduplicationLogger.debug("adding HASH_CODE_FIELDS_ALWAYSfield %s to hash_fields: %s", field, getattr(self, field))
30133014
fields_to_hash += str(getattr(self, field))
30143015

30153016
logger.debug("fields_to_hash : %s", fields_to_hash)

dojo/templates/dojo/view_finding.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,7 @@ <h3 class="pull-left finding-title">
538538
<div class="panel panel-default">
539539
<table id="error_notes" class="table-striped table table-condensed table-hover centered">
540540
<tr>
541-
{% if finding.service %}
542541
<th>Service</th>
543-
{% endif %}
544542
{% if finding.file_path %}
545543
<th>Location</th>
546544
{% endif %}
@@ -571,13 +569,11 @@ <h3 class="pull-left finding-title">
571569
{% endif %}
572570
</tr>
573571
<tr>
574-
{% if finding.service %}
575572
<td>
576573
<span>
577574
{{ finding.service }}
578575
</span>
579576
</td>
580-
{% endif %}
581577
{% if finding.file_path %}
582578
<td>
583579
<span>

dojo/test/views.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,15 @@ def process_form(
905905
"minimum_severity": form.cleaned_data.get("minimum_severity"),
906906
"do_not_reactivate": form.cleaned_data.get("do_not_reactivate"),
907907
"tags": form.cleaned_data.get("tags"),
908-
"version": form.cleaned_data.get("version"),
909-
"branch_tag": form.cleaned_data.get("branch_tag", None),
910-
"build_id": form.cleaned_data.get("build_id", None),
911-
"commit_hash": form.cleaned_data.get("commit_hash", None),
912-
"api_scan_configuration": form.cleaned_data.get("api_scan_configuration", None),
913-
"service": form.cleaned_data.get("service", None),
908+
"version": form.cleaned_data.get("version") or None,
909+
"branch_tag": form.cleaned_data.get("branch_tag") or None,
910+
"build_id": form.cleaned_data.get("build_id") or None,
911+
"commit_hash": form.cleaned_data.get("commit_hash") or None,
912+
"api_scan_configuration": form.cleaned_data.get("api_scan_configuration") or None,
913+
"service": form.cleaned_data.get("service") or None,
914914
"apply_tags_to_findings": form.cleaned_data.get("apply_tags_to_findings", False),
915915
"apply_tags_to_endpoints": form.cleaned_data.get("apply_tags_to_endpoints", False),
916-
"group_by": form.cleaned_data.get("group_by", None),
916+
"group_by": form.cleaned_data.get("group_by") or None,
917917
"close_old_findings": form.cleaned_data.get("close_old_findings", None),
918918
"create_finding_groups_for_all_findings": form.cleaned_data.get("create_finding_groups_for_all_findings", None),
919919
})

0 commit comments

Comments
 (0)