Skip to content

Commit 3df94fe

Browse files
committed
Fix tests
1 parent 664c573 commit 3df94fe

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: "OpenReports"
3+
toc_hide: true
4+
---
5+
Import JSON reports from [OpenReports](https://github.com/openreports/reports-api).
6+
7+
### File Types
8+
9+
DefectDojo parser accepts a .json file.
10+
11+
OpenReports JSON files can be exported from Kubernetes clusters using kubectl:
12+
13+
```bash
14+
kubectl get reports -A -ojson > reports.json
15+
```
16+
17+
The parser supports single Report objects, arrays of Reports, or Kubernetes List objects.
18+
19+
### Sample Scan Data
20+
21+
Sample OpenReports scans can be found in the [unittests/scans/openreports directory](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/openreports).

dojo/tools/openreports/parser.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,7 @@ def _create_finding_from_result(self, test, result, service_name, report_name, r
240240
active = result_status not in {"skip", "pass"}
241241
verified = result_status in {"fail", "warn"}
242242

243-
# Create tags
244-
tags = [category, source]
245-
scope_kind = service_name.split("/")[1] if "/" in service_name else ""
246-
if scope_kind:
247-
tags.append(scope_kind)
243+
# Create finding
248244
finding = Finding(
249245
test=test,
250246
title=title,
@@ -261,9 +257,17 @@ def _create_finding_from_result(self, test, result, service_name, report_name, r
261257
dynamic_finding=False,
262258
fix_available=fix_available,
263259
fix_version=fixed_version or None,
264-
unsaved_tags=tags,
265260
)
266261

262+
# Create tags
263+
tags = [category, source]
264+
scope_kind = service_name.split("/")[1] if "/" in service_name else ""
265+
if scope_kind:
266+
tags.append(scope_kind)
267+
268+
# Set unsaved_tags attribute
269+
finding.unsaved_tags = tags
270+
267271
# Add vulnerability ID if it's a CVE
268272
if policy.startswith("CVE-"):
269273
finding.unsaved_vulnerability_ids = [policy]

0 commit comments

Comments
 (0)