Commit 7f0d713e authored by Craig Smith's avatar Craig Smith Committed by Dmytro Zaporozhets

SecurityReportSummary is null if report didn't run

parent 2c122398
......@@ -20,6 +20,8 @@ module Security
private
def summary_counts_for_report_type(report_type, summary_types)
return unless report_exists?(report_type)
summary_types.each_with_object({}) do |summary_type, response|
case summary_type
when :vulnerabilities_count
......@@ -46,5 +48,9 @@ module Security
::Security::ScannedResourcesCountingService.new(@pipeline, requested_report_types(:scanned_resources_count)).execute
end
end
def report_exists?(report_type)
@pipeline&.security_reports&.reports&.key?(report_type.to_s)
end
end
end
---
title: Return null in securityReportSummary when the report didn't run
merge_request: 35218
author:
type: changed
......@@ -98,15 +98,11 @@ describe Security::ReportSummaryService, '#execute' do
))
end
context 'When ran no security scans' do
context 'When no security scans ran' do
let(:pipeline) { create(:ci_pipeline, :success) }
it 'returns 0 vulnerabilities' do
expect(result[:dast][:vulnerabilities_count]).to be(0)
end
it 'returns 0 scanned resources' do
expect(result[:dast][:scanned_resources_count]).to be(0)
it 'returns nil' do
expect(result[:dast]).to be_nil
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment