Commit cd46dc8d authored by Matthias Käppler's avatar Matthias Käppler

Merge branch '346316-catch-yaml-errors-when-parsing-security-policies' into 'master'

Catch YAML errors when parsing security policies

See merge request gitlab-org/gitlab!75092
parents b25d1190 19a5e915
......@@ -357,7 +357,7 @@ scan_execution_policy:
- type: schedule
branches:
- main
cadence: */10 * * * *
cadence: "*/10 * * * *"
actions:
- scan: dast
scanner_profile: Scanner Profile C
......@@ -378,7 +378,7 @@ scan_execution_policy:
enabled: true
rules:
- type: schedule
cadence: '15 3 * * *'
cadence: "15 3 * * *
clusters:
production-cluster:
containers:
......
......@@ -35,6 +35,8 @@ module Security
Gitlab::Config::Loader::Yaml.new(policy_blob).load!
end
rescue Gitlab::Config::Loader::FormatError
nil
end
def policy_configuration_exists?
......
......@@ -102,6 +102,14 @@ RSpec.describe Security::OrchestrationPolicyConfiguration do
it { expect(subject.dig(:scan_execution_policy, 0, :name)).to eq('Run DAST in every pipeline') }
end
context 'when policy has invalid YAML format' do
let(:policy_yaml) do
'cadence: * 1 2 3'
end
it { expect(subject).to be_nil }
end
context 'when policy is nil' do
let(:policy_yaml) { nil }
......
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