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