Commit adc8dfeb authored by Tetiana Chupryna's avatar Tetiana Chupryna

Move LatestPipelineInformation to CE

As SAST and SecretDetection are moved to FOSS,
we need to move related code as well.
This change is a prerequisite change to move
unify Security Configuration between FOSS and EE

Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/342135
parent 8f92de9c
# frozen_string_literal: true
module Security
module LatestPipelineInformation
private
def scanner_enabled?(scan_type)
latest_builds_reports.include?(scan_type)
end
def latest_builds_reports(only_successful_builds: false)
strong_memoize("latest_builds_reports_#{only_successful_builds}") do
builds = latest_security_builds
builds = builds.select { |build| build.status == 'success' } if only_successful_builds
builds.flat_map do |build|
build.options[:artifacts][:reports].keys
end
end
end
def latest_security_builds
return [] unless latest_default_branch_pipeline
::Security::SecurityJobsFinder.new(pipeline: latest_default_branch_pipeline).execute +
::Security::LicenseComplianceJobsFinder.new(pipeline: latest_default_branch_pipeline).execute
end
def latest_default_branch_pipeline
strong_memoize(:pipeline) { latest_pipeline }
end
def auto_devops_source?
latest_default_branch_pipeline&.auto_devops_source?
end
end
end
......@@ -3,7 +3,7 @@
module EE
module ProjectSecurityScannersInformation
include ::Gitlab::Utils::StrongMemoize
include LatestPipelineInformation
include ::Security::LatestPipelineInformation
def available_scanners
all_security_scanners.map { |scanner| scanner.upcase.to_s if feature_available?(scanner) }.compact
......
# frozen_string_literal: true
module LatestPipelineInformation
private
def scanner_enabled?(scan_type)
latest_builds_reports.include?(scan_type)
end
def latest_builds_reports(only_successful_builds: false)
strong_memoize("latest_builds_reports_#{only_successful_builds}" ) do
builds = latest_security_builds
builds = builds.select { |build| build.status == 'success' } if only_successful_builds
builds.flat_map do |build|
build.options[:artifacts][:reports].keys
end
end
end
def latest_security_builds
return [] unless latest_default_branch_pipeline
::Security::SecurityJobsFinder.new(pipeline: latest_default_branch_pipeline).execute +
::Security::LicenseComplianceJobsFinder.new(pipeline: latest_default_branch_pipeline).execute
end
def latest_default_branch_pipeline
strong_memoize(:pipeline) { latest_pipeline }
end
def auto_devops_source?
latest_default_branch_pipeline&.auto_devops_source?
end
end
......@@ -5,7 +5,7 @@ module Projects
class ConfigurationPresenter < Gitlab::View::Presenter::Delegated
include Gitlab::Utils::StrongMemoize
include AutoDevopsHelper
include LatestPipelineInformation
include ::Security::LatestPipelineInformation
delegator_override_with Gitlab::Utils::StrongMemoize # TODO: Remove `Gitlab::Utils::StrongMemoize` inclusion as it's duplicate
......
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