Class: Gitlab::Ci::Reports::Security::Report
- Inherits:
-
Object
- Object
- Gitlab::Ci::Reports::Security::Report
- Defined in:
- lib/gitlab/ci/reports/security/report.rb
Instance Attribute Summary collapse
-
#analyzer ⇒ Object
Returns the value of attribute analyzer.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#pipeline ⇒ Object
Returns the value of attribute pipeline.
-
#scan ⇒ Object
Returns the value of attribute scan.
-
#scanned_resources ⇒ Object
Returns the value of attribute scanned_resources.
-
#scanners ⇒ Object
readonly
Returns the value of attribute scanners.
-
#schema_validation_status ⇒ Object
Returns the value of attribute schema_validation_status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Instance Method Summary collapse
- #add_error(type, message = 'An unexpected error happened!') ⇒ Object
- #add_finding(finding) ⇒ Object
- #add_identifier(identifier) ⇒ Object
- #add_scanner(scanner) ⇒ Object
- #add_warning(type, message) ⇒ Object
- #clone_as_blank ⇒ Object
- #commit_sha ⇒ Object
- #errored? ⇒ Boolean
- #has_signatures? ⇒ Boolean
-
#initialize(type, pipeline, created_at) ⇒ Report
constructor
A new instance of Report.
- #merge!(other) ⇒ Object
- #primary_identifiers ⇒ Object
- #primary_scanner ⇒ Object
- #primary_scanner_order_to(other) ⇒ Object
- #replace_with!(other) ⇒ Object
- #warnings? ⇒ Boolean
Constructor Details
#initialize(type, pipeline, created_at) ⇒ Report
Returns a new instance of Report.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 15 def initialize(type, pipeline, created_at) @type = type @pipeline = pipeline @created_at = created_at @findings = [] @scanners = {} @identifiers = {} @scanned_resources = [] @errors = [] @warnings = [] end |
Instance Attribute Details
#analyzer ⇒ Object
Returns the value of attribute analyzer.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def analyzer @analyzer end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 8 def created_at @created_at end |
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def errors @errors end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
8 9 10 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 8 def findings @findings end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
8 9 10 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 8 def identifiers @identifiers end |
#pipeline ⇒ Object
Returns the value of attribute pipeline.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def pipeline @pipeline end |
#scan ⇒ Object
Returns the value of attribute scan.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def scan @scan end |
#scanned_resources ⇒ Object
Returns the value of attribute scanned_resources.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def scanned_resources @scanned_resources end |
#scanners ⇒ Object (readonly)
Returns the value of attribute scanners.
8 9 10 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 8 def scanners @scanners end |
#schema_validation_status ⇒ Object
Returns the value of attribute schema_validation_status.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def schema_validation_status @schema_validation_status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 8 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def version @version end |
#warnings ⇒ Object
Returns the value of attribute warnings.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 9 def warnings @warnings end |
Instance Method Details
#add_error(type, message = 'An unexpected error happened!') ⇒ Object
31 32 33 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 31 def add_error(type, = 'An unexpected error happened!') errors << { type: type, message: } end |
#add_finding(finding) ⇒ Object
55 56 57 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 55 def add_finding(finding) findings << finding end |
#add_identifier(identifier) ⇒ Object
51 52 53 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 51 def add_identifier(identifier) identifiers[identifier.key] ||= identifier end |
#add_scanner(scanner) ⇒ Object
47 48 49 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 47 def add_scanner(scanner) scanners[scanner.key] ||= scanner end |
#add_warning(type, message) ⇒ Object
35 36 37 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 35 def add_warning(type, ) warnings << { type: type, message: } end |
#clone_as_blank ⇒ Object
59 60 61 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 59 def clone_as_blank Report.new(type, pipeline, created_at) end |
#commit_sha ⇒ Object
27 28 29 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 27 def commit_sha pipeline.sha end |
#errored? ⇒ Boolean
39 40 41 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 39 def errored? errors.present? end |
#has_signatures? ⇒ Boolean
88 89 90 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 88 def has_signatures? findings.any?(&:has_signatures?) end |
#merge!(other) ⇒ Object
69 70 71 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 69 def merge!(other) replace_with!(::Security::MergeReportsService.new(self, other).execute) end |
#primary_identifiers ⇒ Object
73 74 75 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 73 def primary_identifiers scanners.values.flat_map(&:primary_identifiers).compact end |
#primary_scanner ⇒ Object
77 78 79 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 77 def primary_scanner scanners.first&.second end |
#primary_scanner_order_to(other) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 81 def primary_scanner_order_to(other) return 1 unless primary_scanner return -1 unless other.primary_scanner primary_scanner <=> other.primary_scanner end |
#replace_with!(other) ⇒ Object
63 64 65 66 67 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 63 def replace_with!(other) instance_variables.each do |ivar| instance_variable_set(ivar, other.public_send(ivar.to_s[1..])) # rubocop:disable GitlabSecurity/PublicSend end end |
#warnings? ⇒ Boolean
43 44 45 |
# File 'lib/gitlab/ci/reports/security/report.rb', line 43 def warnings? warnings.present? end |