-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add OpenReports import support #13562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
valentijnscholten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! It looks quite good already. Some questions:
- Can you add at least one vulnerability for which the policy field is not a CVE?
- Could you look at the hash_code configuration for deduplication? It might be good to check wha the best fit ir or if there's a field that we can use as a value for
unique_id_from_tool.
manuel-sommer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a documentation file for the parser.
8cbb5ca to
7647272
Compare
|
I think also if this is a generic report format similar to SARIF, the openreports parser should do something similar where the actual report type / scanner type ends up in the test name in Defect Dojo. django-DefectDojo/dojo/tools/sarif/parser.py Lines 113 to 117 in 16c749c
|
01dc290 to
53ef8bb
Compare
valentijnscholten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for extending the PR. The values for the scanner names seem a bit generic and may change in the future if more operators/scanners will use this output format, but that's outside our control.
valentijnscholten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, forgot that there were some small issues to address.
|
Conflicts have been resolved. A maintainer will review the pull request shortly. |
|
Changing to draft status until it's ready. |
|
This pull request introduces a parser (OpenreportsParser) that reads uploaded scan files into memory without size limits, which could allow a maliciously large upload to exhaust process memory and cause a Denial of Service. Consider adding file size checks, streaming/iterative processing, or explicit limits and error handling to mitigate the risk.
Resource Exhaustion (Denial of Service) in
|
| Vulnerability | Resource Exhaustion (Denial of Service) |
|---|---|
| Description | The OpenreportsParser reads the entire uploaded scan file into memory using scan_file.read() without any explicit size limitations within the parser. A malicious user could upload an extremely large file, causing the application process to consume excessive memory, potentially leading to a Denial of Service (DoS) by crashing the process. |
django-DefectDojo/dojo/tools/openreports/parser.py
Lines 43 to 46 in 57c68bb
| scan_data = scan_file.read() | |
| try: | |
| data = json.loads(str(scan_data, "utf-8")) |
All finding details can be found in the DryRun Security Dashboard.
|
Marked as draft for now. Can you fix the failing tests @mfyll |
Should be OK now. |
|
This pull request adds or modifies an OpenreportsParser that reads the entire uploaded report file into memory via scan_file.read() without size validation, which could allow a maliciously large upload to exhaust memory and cause a Denial of Service. Consider validating or limiting file size and streaming processing to avoid loading the whole file into memory.
Resource Exhaustion (Denial of Service) in
|
| Vulnerability | Resource Exhaustion (Denial of Service) |
|---|---|
| Description | The OpenreportsParser reads the entire uploaded report file into memory using scan_file.read() without any explicit size validation. While Django, the underlying framework, spools large files (by default, > 2.5MB) to disk, the parser's subsequent read() operation will still attempt to load the entire content of this potentially very large file from disk back into the application's memory. A malicious actor could upload an extremely large file, causing the application to consume excessive memory, leading to a Denial of Service (DoS) by crashing the process. |
django-DefectDojo/dojo/tools/openreports/parser.py
Lines 43 to 46 in 3df94fe
| scan_data = scan_file.read() | |
| try: | |
| data = json.loads(str(scan_data, "utf-8")) |
All finding details can be found in the DryRun Security Dashboard.
|
Some failures. Please note the folder location of the parser has changed. |
|
Thank you for the PR, approved. |
mtesauro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Add OpenReports JSON Import Parser
Description
Adds support for importing scans in OpenReports.io format. Currently only statnett operator outputs trivy scans in this format, but being an open standard backed by e.g kyverno, more tools could adopt it.
More information can be found here: OpenReports.io
Steps to get the relevant file:
kubectl get reports -ojson -A > reports.jsonFeatures:
Test results
Added unit tests covering empty results, single reports, list format, and parser metadata. All tests pass with sample JSON files included.
I have also tested this by importing the resulting JSON file in the DefectDojo GUI and this works.
Documentation
Parser follows standard DefectDojo interface with inline documentation and sample files.
Checklist