Sonarqube API import still fails when using OWASP dependency-check
Bug description Since the following issue has been marked as fixed #6339 , I tried the Sonarqube API import with the newest version of DefectDojo but the import still doesn't seem to work when using the Sonarqube API import in combination with findings from OWASP dependency check . The error (see logs) is the same as in issue #6339.
Deployment method
- [ ] Docker Compose
- [X ] Kubernetes
- [ ] GoDojo
Environment information
- DefectDojo: 2.11.0
- Sonarqube: 9.5
- OWASP dependency-check: 7.1.0
- OWASP sonar-dependency-check: 3.0.1
Logs
/usr/local/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1358: RuntimeWarning: DateTimeField Test.target_start received a naive datetime (2022-07-03 00:00:00) while time zone support is active.
warnings.warn("DateTimeField %s.%s received a naive datetime "
/usr/local/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1358: RuntimeWarning: DateTimeField Test.target_end received a naive datetime (2022-07-03 00:00:00) while time zone support is active.
warnings.warn("DateTimeField %s.%s received a naive datetime "
[03/Jul/2022 16:49:53] ERROR [dojo.tools.sonarqube_api.importer:230] 'vulnerabilityDescription'
Traceback (most recent call last):
File "/app/./dojo/tools/sonarqube_api/importer.py", line 191, in import_hotspots
description = self.clean_rule_description_html(rule['vulnerabilityDescription'])
KeyError: 'vulnerabilityDescription'
[03/Jul/2022 16:49:53] ERROR [dojo.engagement.views:637] 'NoneType' object is not iterable
Traceback (most recent call last):
File "/app/./dojo/engagement/views.py", line 622, in import_scan_results
test, finding_count, closed_finding_count, _ = importer.import_scan(scan, scan_type, engagement, user, environment, active=active, verified=verified, tags=tags,
File "/app/./dojo/importers/importer/importer.py", line 297, in import_scan
parsed_findings = parser.get_findings(scan, test)
File "/app/./dojo/tools/sonarqube_api/parser.py", line 25, in get_findings
return SonarQubeApiImporter().get_findings(json_output, test)
File "/app/./dojo/tools/sonarqube_api/importer.py", line 26, in get_findings
items.extend(self.import_hotspots(test))
TypeError: 'NoneType' object is not iterable
Screenshots

How have you installed DefectDojo and what does the version on the bottom of the pages say?
The line that causes the problem is different on the master branch compared to what your logs are: https://github.com/DefectDojo/django-DefectDojo/blob/c101e47b294863877cd68a82d0cc60f8017b45b1/dojo/tools/sonarqube_api/importer.py#L191
I have used the latest helm chart to install Defectdojo. Here is a screen of the version on the bottom:
and the docker image tag used is defectdojo/defectdojo-django:2.11.0
I have downloaded importer.py from the pod (see attached file) but line 191 seems to be different:
description = self.clean_rule_description_html(rule['vulnerabilityDescription'])
importer.txt
Due to problems with the Bitnami repository for helm charts, the release didn't work as planned. The version you are running is basically the same as release 2.10.0. This is why the changes are not there. The next release is planned for tomorrow, it should be fixed then.
I have just tested this on 2.12.0 and getting the following error:
[06/Jul/2022 06:01:16] ERROR [dojo.tools.sonarqube_api.importer:232] 'NoneType' object has no attribute 'iter'
Traceback (most recent call last):
File "/app/./dojo/tools/sonarqube_api/importer.py", line 194, in import_hotspots
references = self.get_references(rule.get('riskDescription', '')) + self.get_references(rule.get('fixRecommendations', ''))
File "/app/./dojo/tools/sonarqube_api/importer.py", line 288, in get_references
for a in details.iter("a"):
AttributeError: 'NoneType' object has no attribute 'iter'
[06/Jul/2022 06:01:16] ERROR [dojo.engagement.views:641] 'NoneType' object is not iterable
Traceback (most recent call last):
File "/app/./dojo/engagement/views.py", line 626, in import_scan_results
test, finding_count, closed_finding_count, _ = importer.import_scan(scan, scan_type, engagement, user, environment, active=active, verified=verified, tags=tags,
File "/app/./dojo/importers/importer/importer.py", line 298, in import_scan
parsed_findings = parser.get_findings(scan, test)
File "/app/./dojo/tools/sonarqube_api/parser.py", line 25, in get_findings
return SonarQubeApiImporter().get_findings(json_output, test)
File "/app/./dojo/tools/sonarqube_api/importer.py", line 26, in get_findings
items.extend(self.import_hotspots(test))
TypeError: 'NoneType' object is not iterable


Unfortunately the bugfix worked only partially, #6530 should work better.
I just tested #6530 and can confirm that this solution works
merged for release 2.13