Commit 2530bc0c authored by Kamil Trzciński's avatar Kamil Trzciński

Support returning a new pipelines

parent c3ff1702
......@@ -5,7 +5,7 @@ module Projects
before_action :authorize_read_project_security_dashboard!
def show
@pipeline = @project.latest_pipeline_with_legacy_security_reports
@pipeline = @project.latest_pipeline_with_security_reports
&.present(current_user: current_user)
end
......
......@@ -16,9 +16,14 @@ module EE
has_many :vulnerabilities, source: :occurrence, through: :vulnerabilities_occurrence_pipelines, class_name: 'Vulnerabilities::Occurrence'
# Legacy way to fetch security reports based on job name. This has been replaced by the reports feature.
scope :with_legacy_security_reports, -> {
scope :with_legacy_security_reports, -> do
joins(:artifacts).where(ci_builds: { name: %w[sast dependency_scanning sast:container container_scanning dast] })
}
end
# The new `reports:` syntax reports
scope :with_security_reports, -> do
where('EXISTS (?)', Ci::Build.select(1).latest.with_security_reports.where('ci_pipelines.id=ci_build.commit_id'))
end
# This structure describes feature levels
# to access the file types for given reports
......
......@@ -109,8 +109,9 @@ module EE
end
end
def latest_pipeline_with_legacy_security_reports
pipelines.newest_first(default_branch).with_legacy_security_reports.first
def latest_pipeline_with_security_reports
pipelines.newest_first(default_branch).with_security_reports.first ||
pipelines.newest_first(default_branch).with_legacy_security_reports.first
end
def environments_for_scope(scope)
......
......@@ -1496,7 +1496,7 @@ describe Project do
end
end
describe '#latest_pipeline_with_legacy_security_reports' do
describe '#latest_pipeline_with_security_reports' do
let(:project) { create(:project) }
let(:pipeline_1) { create(:ci_pipeline_without_jobs, project: project) }
let(:pipeline_2) { create(:ci_pipeline_without_jobs, project: project) }
......
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