Security Dashboard fails to load when location isn't present
Summary
The security dashboard is failing when vulnerabilities do not have a location attribute.
Steps to reproduce
Run Container Scanning or DAST on a project and if they have vulnerabilities, the dashboard will fail to load.
Relevant logs and/or screenshots
TypeError at /groups/reports/-/security/vulnerabilities
=======================================================
> no implicit conversion of nil into String
ee/app/presenters/vulnerabilities/occurrence_presenter.rb, line 25
------------------------------------------------------------------
20 complete_path << "-#{end_line}" if end_line
21 end
22 end
23
24 def vulnerability_path
> 25 @vulnerability_path ||= project_blob_path(project, File.join(sha, location['file']))
26 end
27 end
28 end
App backtrace
-------------
- ee/app/presenters/vulnerabilities/occurrence_presenter.rb:25:in `vulnerability_path'
- ee/app/presenters/vulnerabilities/occurrence_presenter.rb:16:in `add_line_numbers'
- ee/app/presenters/vulnerabilities/occurrence_presenter.rb:10:in `blob_path'
- ee/app/serializers/vulnerabilities/occurrence_entity.rb:27:in `block in <class:OccurrenceEntity>'
- app/serializers/base_serializer.rb:16:in `represent'
- app/serializers/concerns/with_pagination.rb:19:in `represent'
- ee/app/serializers/vulnerabilities/occurrence_serializer.rb:17:in `represent'
- ee/app/controllers/groups/security/vulnerabilities_controller.rb:14:in `block (2 levels) in index'
- ee/app/controllers/groups/security/vulnerabilities_controller.rb:9:in `index'
- lib/gitlab/i18n.rb:55:in `with_locale'
- lib/gitlab/i18n.rb:61:in `with_user_locale'