Commit 54e023cf authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'mc_rocha-consider-non-default-config-file-for-security-ui-351856' into 'master'

Consider non-default config files for Security UI

See merge request gitlab-org/gitlab!81027
parents e0f5dc24 9a74d9ba
......@@ -41,7 +41,7 @@ module Security
end
def existing_gitlab_ci_content
@gitlab_ci_yml ||= project.repository.gitlab_ci_yml_for(project.repository.root_ref_sha)
@gitlab_ci_yml ||= project.ci_config_for(project.repository.root_ref_sha)
YAML.safe_load(@gitlab_ci_yml) if @gitlab_ci_yml
end
......
......@@ -6,7 +6,8 @@ module Security
private
def action
Security::CiConfiguration::ContainerScanningBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content).generate
Security::CiConfiguration::ContainerScanningBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content,
project.ci_config_path).generate
end
def next_branch
......
......@@ -6,7 +6,8 @@ module Security
private
def action
Security::CiConfiguration::DependencyScanningBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content).generate
Security::CiConfiguration::DependencyScanningBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content,
project.ci_config_path).generate
end
def next_branch
......
......@@ -26,7 +26,7 @@ module Security
nil
end
Security::CiConfiguration::SastBuildAction.new(project.auto_devops_enabled?, params, existing_content).generate
Security::CiConfiguration::SastBuildAction.new(project.auto_devops_enabled?, params, existing_content, project.ci_config_path).generate
end
def next_branch
......
......@@ -6,7 +6,8 @@ module Security
private
def action
Security::CiConfiguration::SastIacBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content).generate
Security::CiConfiguration::SastIacBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content,
project.ci_config_path).generate
end
def next_branch
......
......@@ -6,7 +6,8 @@ module Security
private
def action
Security::CiConfiguration::SecretDetectionBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content).generate
Security::CiConfiguration::SecretDetectionBuildAction.new(project.auto_devops_enabled?, existing_gitlab_ci_content,
project.ci_config_path).generate
end
def next_branch
......
......@@ -3,9 +3,10 @@
module Security
module CiConfiguration
class BaseBuildAction
def initialize(auto_devops_enabled, existing_gitlab_ci_content)
def initialize(auto_devops_enabled, existing_gitlab_ci_content, ci_config_path = ::Ci::Pipeline::DEFAULT_CONFIG_PATH)
@auto_devops_enabled = auto_devops_enabled
@existing_gitlab_ci_content = existing_gitlab_ci_content || {}
@ci_config_path = ci_config_path || ::Ci::Pipeline::DEFAULT_CONFIG_PATH
end
def generate
......@@ -13,7 +14,7 @@ module Security
update_existing_content!
{ action: action, file_path: '.gitlab-ci.yml', content: prepare_existing_content, default_values_overwritten: @default_values_overwritten }
{ action: action, file_path: @ci_config_path, content: prepare_existing_content, default_values_overwritten: @default_values_overwritten }
end
private
......
......@@ -3,8 +3,8 @@
module Security
module CiConfiguration
class SastBuildAction < BaseBuildAction
def initialize(auto_devops_enabled, params, existing_gitlab_ci_content)
super(auto_devops_enabled, existing_gitlab_ci_content)
def initialize(auto_devops_enabled, params, existing_gitlab_ci_content, ci_config_path = ::Ci::Pipeline::DEFAULT_CONFIG_PATH)
super(auto_devops_enabled, existing_gitlab_ci_content, ci_config_path)
@variables = variables(params)
@default_sast_values = default_sast_values(params)
@default_values_overwritten = false
......
......@@ -76,6 +76,18 @@ RSpec.shared_examples_for 'services security ci configuration create service' do
end
end
context 'when the project has a non-default ci config file' do
before do
project.ci_config_path = 'non-default/.gitlab-ci.yml'
end
it 'does track the snowplow event' do
subject
expect_snowplow_event(**snowplow_event)
end
end
unless skip_w_params
context 'with parameters' do
let(:params) { non_empty_params }
......
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