Commit b0f84f9d authored by Dmitriy Zaporozhets (DZ)'s avatar Dmitriy Zaporozhets (DZ)

Merge branch 'fix_schema_validation' into 'master'

Fix security report schema validation

See merge request gitlab-org/gitlab!69292
parents d536f211 2b0a3380
......@@ -8,11 +8,13 @@ module EE
module SchemaValidator
module Schema
extend ::Gitlab::Utils::Override
CE_TYPES = %i(sast secret_detection).freeze
override :root_path
def root_path
if [:sast, :secret_detection].include?(report_type)
super
else
return super if CE_TYPES.include?(report_type)
File.join(__dir__, 'schemas')
end
end
......@@ -22,5 +24,4 @@ module EE
end
end
end
end
end
......@@ -12,7 +12,7 @@ module Gitlab
end
def initialize(report_type)
@report_type = report_type
@report_type = report_type.to_sym
end
delegate :validate, to: :schemer
......
......@@ -6,6 +6,7 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator do
using RSpec::Parameterized::TableSyntax
where(:report_type, :expected_errors, :valid_data) do
'sast' | ['root is missing required keys: vulnerabilities'] | { 'version' => '10.0.0', 'vulnerabilities' => [] }
:sast | ['root is missing required keys: vulnerabilities'] | { 'version' => '10.0.0', 'vulnerabilities' => [] }
:secret_detection | ['root is missing required keys: vulnerabilities'] | { 'version' => '10.0.0', 'vulnerabilities' => [] }
end
......
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