Commit 3c279004 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'secure-refactor-common-parser' into 'master'

Move duplicating code

See merge request gitlab-org/gitlab-ee!9146
parents aac62d39 96c1c465
# frozen_string_literal: true
module Gitlab
module Ci
module Parsers
module Security
module Concerns
module DeprecatedSyntax
extend ActiveSupport::Concern
included do
extend ::Gitlab::Utils::Override
override :parse_report
end
def parse_report(json_data)
report = super
if report.is_a?(Array)
puts self.class
report = {
"version" => self.class::DEPRECATED_REPORT_VERSION,
"vulnerabilities" => report
}
end
report
end
end
end
end
end
end
end
......@@ -5,24 +5,10 @@ module Gitlab
module Parsers
module Security
class ContainerScanning < Common
extend ::Gitlab::Utils::Override
include Security::Concerns::DeprecatedSyntax
DEPRECATED_REPORT_VERSION = "1.3".freeze
override :parse_report
def parse_report(json_data)
report = super
if report.is_a?(Array)
report = {
"version" => DEPRECATED_REPORT_VERSION,
"vulnerabilities" => report
}
end
report
end
def parse!(json_data, report)
vulnerabilities = format_report(JSON.parse!(json_data))
......
......@@ -5,26 +5,12 @@ module Gitlab
module Parsers
module Security
class DependencyScanning < Common
extend ::Gitlab::Utils::Override
include Security::Concerns::DeprecatedSyntax
DEPRECATED_REPORT_VERSION = "1.3".freeze
private
override :parse_report
def parse_report(json_data)
report = super
if report.is_a?(Array)
report = {
"version" => DEPRECATED_REPORT_VERSION,
"vulnerabilities" => report
}
end
report
end
def generate_location_fingerprint(location)
Digest::SHA1.hexdigest("#{location['file']}:#{location.dig('dependency', 'package', 'name')}")
end
......
......@@ -5,26 +5,12 @@ module Gitlab
module Parsers
module Security
class Sast < Common
extend ::Gitlab::Utils::Override
include Security::Concerns::DeprecatedSyntax
DEPRECATED_REPORT_VERSION = "1.2".freeze
private
override :parse_report
def parse_report(json_data)
report = super
if report.is_a?(Array)
report = {
"version" => DEPRECATED_REPORT_VERSION,
"vulnerabilities" => report
}
end
report
end
def generate_location_fingerprint(location)
Digest::SHA1.hexdigest("#{location['file']}:#{location['start_line']}:#{location['end_line']}")
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