Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-03-08 21:55:36 +00:00
parent 94cb5cf7da
commit b2066dcc69
9 changed files with 27 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 }