Commit b9197e95 authored by Olivier Gonzalez's avatar Olivier Gonzalez

Fix scoping vulns on group dashboard

Ensure we only filter pipeline that effectively have vulnerabilties.
parent dcffe1f7
...@@ -25,6 +25,10 @@ module EE ...@@ -25,6 +25,10 @@ module EE
where('EXISTS (?)', ::Ci::Build.latest.with_security_reports.where('ci_pipelines.id=ci_builds.commit_id').select(1)) where('EXISTS (?)', ::Ci::Build.latest.with_security_reports.where('ci_pipelines.id=ci_builds.commit_id').select(1))
end end
scope :with_vulnerabilities, -> do
where('EXISTS (?)', ::Vulnerabilities::OccurrencePipeline.where('ci_pipelines.id=vulnerability_occurrence_pipelines.pipeline_id').select(1))
end
# This structure describes feature levels # This structure describes feature levels
# to access the file types for given reports # to access the file types for given reports
REPORT_LICENSED_FEATURES = { REPORT_LICENSED_FEATURES = {
......
...@@ -84,7 +84,7 @@ module EE ...@@ -84,7 +84,7 @@ module EE
def latest_vulnerabilities def latest_vulnerabilities
Vulnerabilities::Occurrence Vulnerabilities::Occurrence
.for_pipelines(all_pipelines.latest_successful_ids_per_project) .for_pipelines(all_pipelines.with_vulnerabilities.latest_successful_ids_per_project)
end end
def human_ldap_access def human_ldap_access
......
...@@ -40,6 +40,21 @@ describe Ci::Pipeline do ...@@ -40,6 +40,21 @@ describe Ci::Pipeline do
end end
end end
describe '#with_vulnerabilities scope' do
let!(:pipeline_1) { create(:ci_pipeline_without_jobs, project: project) }
let!(:pipeline_2) { create(:ci_pipeline_without_jobs, project: project) }
let!(:pipeline_3) { create(:ci_pipeline_without_jobs, project: project) }
before do
create(:vulnerabilities_occurrence, pipelines: [pipeline_1], project: pipeline.project)
create(:vulnerabilities_occurrence, pipelines: [pipeline_2], project: pipeline.project)
end
it "returns pipeline with vulnerabilities" do
expect(described_class.with_vulnerabilities).to contain_exactly(pipeline_1, pipeline_2)
end
end
shared_examples 'unlicensed report type' do shared_examples 'unlicensed report type' do
context 'when there is no licensed feature for artifact file type' do context 'when there is no licensed feature for artifact file type' do
it 'returns the artifact' do it 'returns the artifact' do
......
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