Commit 38decf0b authored by Fabio Pitino's avatar Fabio Pitino

Merge branch '230825-follow-up-scanner-type-enum' into 'master'

Return no scanners when pipeline has no reports

See merge request gitlab-org/gitlab!41652
parents 3a26141a 3d4f0b1f
...@@ -15,6 +15,8 @@ module EE ...@@ -15,6 +15,8 @@ module EE
def scanners_run_in_last_pipeline def scanners_run_in_last_pipeline
reports = latest_builds_reports(only_successful_builds: true) 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 all_security_scanners.map { |scanner| scanner.upcase.to_s if reports.include?(scanner) }.compact
end 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 ...@@ -32,12 +32,20 @@ RSpec.describe ::EE::ProjectSecurityScannersInformation do
end end
describe '#scanners_run_by_last_pipeline' do 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 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 end
it 'does not include non-security scanners' do 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 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