DefectDojo / django-DefectDojo

DevSecOps, ASPM, Vulnerability Management. All on one platform.
https://defectdojo.com
BSD 3-Clause "New" or "Revised" License
3.69k stars 1.55k forks source link

APIv2: SonarQube reimport fails (HTTP 500) #5442

Closed kiblik closed 2 years ago

kiblik commented 2 years ago

Be informative/Bug description Before migration [sonarqube_config, cobaltio_config] to api_scan_configuration, it was possible to run reimport without sonarqube_config definition (it automatically detected sonarqube_config from last run). Now, reimport is failing.

Steps to reproduce Run /api/v2/reimport-scan/ on SonarQube Test without api_scan_configuration

Expected behavior

Deployment method (select with an X)

Environment information

Logs

[12/Nov/2021 16:24:53] ERROR [dojo.api_v2.exception_handler:26] 'NoneType' object has no attribute 'tool_configuration'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 18, in create
    serializer.is_valid(raise_exception=True)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 220, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 422, in run_validation
    value = self.validate(value)
  File "/app/./dojo/api_v2/serializers.py", line 1376, in validate
    if tool_type != api_scan_configuration.tool_configuration.tool_type.name:
AttributeError: 'NoneType' object has no attribute 'tool_configuration'
[12/Nov/2021 16:24:53] ERROR [django.request:224] Internal Server Error: /api/v2/reimport-scan/
Internal Server Error: /api/v2/reimport-scan/
ERROR:django.request:Internal Server Error: /api/v2/reimport-scan/
[pid: 27|app: 0|req: 102388/182277] 192.168.172.210 () {56 vars in 973 bytes} [Fri Nov 12 16:24:53 2021] POST /api/v2/reimport-scan/ => generated 59 bytes in 20 msecs (HTTP/1.1 500) 7 headers in 212 bytes (1 switches on core 1)
StefanFl commented 2 years ago

merged for release 2.5.0