Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/reports/security/finding.rb')
-rw-r--r--lib/gitlab/ci/reports/security/finding.rb40
1 files changed, 35 insertions, 5 deletions
diff --git a/lib/gitlab/ci/reports/security/finding.rb b/lib/gitlab/ci/reports/security/finding.rb
index 39531e12f69..47ec82ac86c 100644
--- a/lib/gitlab/ci/reports/security/finding.rb
+++ b/lib/gitlab/ci/reports/security/finding.rb
@@ -17,7 +17,6 @@ module Gitlab
attr_reader :name
attr_reader :old_location
attr_reader :project_fingerprint
- attr_reader :raw_metadata
attr_reader :report_type
attr_reader :scanner
attr_reader :scan
@@ -28,10 +27,13 @@ module Gitlab
attr_reader :details
attr_reader :signatures
attr_reader :project_id
+ attr_reader :original_data
delegate :file_path, :start_line, :end_line, to: :location
- def initialize(compare_key:, identifiers:, flags: [], links: [], remediations: [], location:, metadata_version:, name:, raw_metadata:, report_type:, scanner:, scan:, uuid:, confidence: nil, severity: nil, details: {}, signatures: [], project_id: nil, vulnerability_finding_signatures_enabled: false) # rubocop:disable Metrics/ParameterLists
+ alias_method :cve, :compare_key
+
+ def initialize(compare_key:, identifiers:, flags: [], links: [], remediations: [], location:, metadata_version:, name:, original_data:, report_type:, scanner:, scan:, uuid:, confidence: nil, severity: nil, details: {}, signatures: [], project_id: nil, vulnerability_finding_signatures_enabled: false) # rubocop:disable Metrics/ParameterLists
@compare_key = compare_key
@confidence = confidence
@identifiers = identifiers
@@ -40,7 +42,7 @@ module Gitlab
@location = location
@metadata_version = metadata_version
@name = name
- @raw_metadata = raw_metadata
+ @original_data = original_data
@report_type = report_type
@scanner = scanner
@scan = scan
@@ -74,6 +76,10 @@ module Gitlab
uuid
details
signatures
+ description
+ message
+ cve
+ solution
].each_with_object({}) do |key, hash|
hash[key] = public_send(key) # rubocop:disable GitlabSecurity/PublicSend
end
@@ -88,8 +94,8 @@ module Gitlab
@location = new_location
end
- def unsafe?(severity_levels)
- severity.in?(severity_levels)
+ def unsafe?(severity_levels, report_types)
+ severity.to_s.in?(severity_levels) && (report_types.blank? || report_type.to_s.in?(report_types) )
end
def eql?(other)
@@ -141,6 +147,30 @@ module Gitlab
scanner <=> other.scanner
end
+ def has_signatures?
+ signatures.present?
+ end
+
+ def raw_metadata
+ @raw_metadata ||= original_data.to_json
+ end
+
+ def description
+ original_data['description']
+ end
+
+ def message
+ original_data['message']
+ end
+
+ def solution
+ original_data['solution']
+ end
+
+ def location_data
+ original_data['location']
+ end
+
private
def generate_project_fingerprint