Commit 3d4f0b1f authored by Alan (Maciej) Paruszewski's avatar Alan (Maciej) Paruszewski Committed by Fabio Pitino

Return no scanners when pipeline has no reports

parent 9063dea6
......@@ -15,6 +15,8 @@ module EE
def scanners_run_in_last_pipeline
reports = latest_builds_reports(only_successful_builds: true)
return [] if reports.empty?
all_security_scanners.map { |scanner| scanner.upcase.to_s if reports.include?(scanner) }.compact
end
......
---
title: Return empty scanners list when pipeline has no reports
merge_request: 41652
author:
type: performance
......@@ -32,12 +32,20 @@ RSpec.describe ::EE::ProjectSecurityScannersInformation do
end
describe '#scanners_run_by_last_pipeline' do
subject(:scanners_run_in_last_pipeline) { project.scanners_run_in_last_pipeline }
context 'when pipeline has no build reports' do
let!(:new_pipeline) { create(:ci_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) }
it { is_expected.to be_empty }
end
it 'returns a list of all scanners which were run successfully in the latest pipeline' do
expect(project.scanners_run_in_last_pipeline).to match_array(%w(DAST SAST))
expect(scanners_run_in_last_pipeline).to match_array(%w(DAST SAST))
end
it 'does not include non-security scanners' do
expect(project.scanners_run_in_last_pipeline).not_to include(%w(LICENSE_SCANNING))
expect(scanners_run_in_last_pipeline).not_to include(%w(LICENSE_SCANNING))
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