You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(importers): stop doubling the (scan_type) suffix in dynamic Test Type names (#15149)
* fix(importers): stop doubling the (scan_type) suffix in dynamic Test Type names
Generic Findings Import (and other dynamic-test-type parsers like SARIF)
built the Test Type name by unconditionally appending " Scan ({scan_type})"
to the report's `type` field. When `type` already carried the
" ({scan_type})" suffix, the suffix was doubled, e.g.
"Prisma Cloud (Generic Findings Import) Scan (Generic Findings Import)".
Extract the name resolution into resolve_dynamic_test_type_name(), which is
now idempotent: a `type` already ending in " ({scan_type})" is used verbatim.
The intentional "{type} Scan ({scan_type})" format is unchanged for all other
cases (Tool1 -> "Tool1 Scan (Generic Findings Import)"), preserving SARIF and
existing behavior.
To avoid breaking existing data, the reimport validation accepts either the
new idempotent name or the legacy (pre-patch) name via
legacy_dynamic_test_type_name(), so reimports into tests whose test_type was
created with the old doubled name keep working without a mismatch error.
Also corrects the Generic Findings Import docs, which described a
"{Test Name} (Generic Findings Import)" format the code never produced.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(importers): restore ' Scan'-suffix guard to stop re-doubling dynamic Test Type names
The idempotency rewrite dropped the legacy guard that returned the scan type
as-is when '{type} Scan' already equals the scan_type. That re-introduced the
exact doubling the PR removes for dynamic parsers whose scan_type ends in
' Scan' (Horusec, AWS Security Hub, Rusty Hog variants), e.g. 'Horusec Scan'
became 'Horusec Scan (Horusec Scan)' on fresh import. Restore the guard and add
a regression test importing a Horusec scan.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/content/asset_modelling/OS_hierarchy/OS__asset_hierarchy.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,6 +159,7 @@ Examples include:
159
159
**Report-Defined Test Type Naming Rules:**
160
160
- If the report's `type` field equals the scan type → uses scan type directly (e.g., "Generic Findings Import")
161
161
- If the report's `type` field differs → creates "{type} Scan ({scan_type})" format (e.g., "Tool1 Scan (Generic Findings Import)")
162
+
- If the report's `type` field already ends with the " ({scan_type})" suffix → uses it verbatim, so the suffix is never doubled (e.g., "Tool1 (Generic Findings Import)" stays "Tool1 (Generic Findings Import)")
162
163
- If no `type` field is provided → uses scan type directly
Copy file name to clipboardExpand all lines: docs/content/asset_modelling/engagements_tests/OS__tests.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ While each method differs primarily in how scan data is parsed and ingested, the
37
37
38
38
When no native parser exists for a given tool, **Generic Findings Import** allows you to import findings using a standardized JSON or CSV schema, regardless of the original source.
39
39
40
-
DefectDojo parses the provided data, creates a new Test (or imports into an existing one), and attaches the Findings. A corresponding Test Type is also created in the format “{Test Name} (Generic Findings Import).”
40
+
DefectDojo parses the provided data, creates a new Test (or imports into an existing one), and attaches the Findings. A corresponding Test Type is also created based on the report's optional `type` field: when `type` is omitted (or equals the scan type) the Test Type is “Generic Findings Import”; when `type` is provided it becomes “{type} Scan (Generic Findings Import)” (a `type` that already ends with the “(Generic Findings Import)” suffix is used verbatim).
Copy file name to clipboardExpand all lines: docs/content/asset_modelling/engagements_tests/PRO__tests.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ While each method differs primarily in how scan data is parsed and ingested, the
35
35
36
36
When no native parser exists for a given tool, [**Generic Findings Import**](/supported_tools/parsers/generic_findings_import) allows you to import findings using a standardized JSON or CSV schema, regardless of the original source.
37
37
38
-
DefectDojo parses the provided data, creates a new Test (or imports into an existing one), and attaches the Findings. A corresponding Test Type is also created in the format “`{Test Name}` (Generic Findings Import).”
38
+
DefectDojo parses the provided data, creates a new Test (or imports into an existing one), and attaches the Findings. A corresponding Test Type is also created based on the report's optional `type` field: when `type` is omitted (or equals the scan type) the Test Type is “Generic Findings Import”; when `type` is provided it becomes “`{type}`Scan (Generic Findings Import)” (a `type` that already ends with the “(Generic Findings Import)” suffix is used verbatim).
Copy file name to clipboardExpand all lines: docs/content/supported_tools/parsers/file/generic.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,6 +226,8 @@ Example:
226
226
}
227
227
```
228
228
229
+
The resulting Test Type name is derived from the `type` field: when `type` is omitted (or equals the scan type) the Test Type is `Generic Findings Import`; when `type` is provided it becomes `{type} Scan (Generic Findings Import)` (for the example above, `My custom Test type Scan (Generic Findings Import)`). A `type` that already ends with the `(Generic Findings Import)` suffix is used verbatim, so the suffix is never doubled.
230
+
229
231
### Sample Scan Data
230
232
231
233
Sample Generic Findings Import scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/generic).
Copy file name to clipboardExpand all lines: docs/content/supported_tools/parsers/generic_findings_import.md
+22-8Lines changed: 22 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,28 @@ weight: 2
6
6
7
7
Open-source and Pro users can use Generic Findings Import as a method to ingest JSON or CSV files into DefectDojo which are not already in the supported Tools list.
8
8
9
-
Using Generic Findings Import will create a new Test Type in your DefectDojo instance called "`{The Name Of Your Test}` (Generic Findings Import)". For example, this JSON content will result in a Test Type called "Example Report (Generic Findings Import)":
10
-
11
-
```
12
-
{
13
-
"name": "Example Report",
14
-
"findings": []
15
-
}
16
-
```
9
+
Using Generic Findings Import creates a Test Type in your DefectDojo instance based on the optional `type` field in the report. The naming rules are:
10
+
11
+
- If no `type` field is provided (or it equals the scan type), the Test Type is simply **"Generic Findings Import"**. For example, this JSON content results in the Test Type "Generic Findings Import":
12
+
13
+
```
14
+
{
15
+
"name": "Example Report",
16
+
"findings": []
17
+
}
18
+
```
19
+
20
+
- If a `type` field is provided and differs from the scan type, the Test Type is **"`{type}` Scan (Generic Findings Import)"**. For example, `"type": "Tool1"` results in the Test Type "Tool1 Scan (Generic Findings Import)":
21
+
22
+
```
23
+
{
24
+
"name": "Example Report",
25
+
"type": "Tool1",
26
+
"findings": []
27
+
}
28
+
```
29
+
30
+
- If the `type` field already ends with the "(Generic Findings Import)" suffix, it is used verbatim (the suffix is never doubled). For example, `"type": "Tool1 (Generic Findings Import)"` results in the Test Type "Tool1 (Generic Findings Import)".
17
31
18
32
DefectDojo Pro users can also consider using the [Universal Parser](../universal_parser), a tool which allows for highly customizable JSON, XML and CSV imports.
0 commit comments