diff options
Diffstat (limited to 'lib/gitlab/ci/parsers')
-rw-r--r-- | lib/gitlab/ci/parsers/security/common.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/ci/parsers/security/validators/schema_validator.rb | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/gitlab/ci/parsers/security/common.rb b/lib/gitlab/ci/parsers/security/common.rb index 41acb4d5040..1cf4f252ab9 100644 --- a/lib/gitlab/ci/parsers/security/common.rb +++ b/lib/gitlab/ci/parsers/security/common.rb @@ -86,6 +86,7 @@ module Gitlab def create_finding(data, remediations = []) identifiers = create_identifiers(data['identifiers']) + flags = create_flags(data['flags']) links = create_links(data['links']) location = create_location(data['location'] || {}) signatures = create_signatures(tracking_data(data)) @@ -111,6 +112,7 @@ module Gitlab scanner: create_scanner(data['scanner']), scan: report&.scan, identifiers: identifiers, + flags: flags, links: links, remediations: remediations, raw_metadata: data.to_json, @@ -205,6 +207,18 @@ module Gitlab url: identifier['url'])) end + def create_flags(flags) + return [] unless flags.is_a?(Array) + + flags.map { |flag| create_flag(flag) }.compact + end + + def create_flag(flag) + return unless flag.is_a?(Hash) + + ::Gitlab::Ci::Reports::Security::Flag.new(type: flag['type'], origin: flag['origin'], description: flag['description']) + end + def create_links(links) return [] unless links.is_a?(Array) diff --git a/lib/gitlab/ci/parsers/security/validators/schema_validator.rb b/lib/gitlab/ci/parsers/security/validators/schema_validator.rb index 3d92886cba8..143b930c669 100644 --- a/lib/gitlab/ci/parsers/security/validators/schema_validator.rb +++ b/lib/gitlab/ci/parsers/security/validators/schema_validator.rb @@ -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 |