Class: Gitlab::Ci::Reports::Security::Identifier
- Inherits:
-
Object
- Object
- Gitlab::Ci::Reports::Security::Identifier
- Defined in:
- lib/gitlab/ci/reports/security/identifier.rb
Instance Attribute Summary collapse
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#external_type ⇒ Object
readonly
Returns the value of attribute external_type.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cve? ⇒ Boolean
- #cwe? ⇒ Boolean
-
#initialize(external_id:, external_type:, name:, url: nil) ⇒ Identifier
constructor
A new instance of Identifier.
- #key ⇒ Object
- #to_hash ⇒ Object
- #type_identifier? ⇒ Boolean
- #wasc? ⇒ Boolean
Constructor Details
#initialize(external_id:, external_type:, name:, url: nil) ⇒ Identifier
Returns a new instance of Identifier.
14 15 16 17 18 19 20 21 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 14 def initialize(external_id:, external_type:, name:, url: nil) @external_id = external_id @external_type = external_type @name = name @url = url @fingerprint = generate_fingerprint end |
Instance Attribute Details
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
8 9 10 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 8 def external_id @external_id end |
#external_type ⇒ Object (readonly)
Returns the value of attribute external_type.
9 10 11 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 9 def external_type @external_type end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
10 11 12 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 10 def fingerprint @fingerprint end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 11 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
12 13 14 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 12 def url @url end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 39 def ==(other) other.external_type == external_type && other.external_id == external_id end |
#cve? ⇒ Boolean
48 49 50 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 48 def cve? external_type.to_s.casecmp?('cve') end |
#cwe? ⇒ Boolean
52 53 54 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 52 def cwe? external_type.to_s.casecmp?('cwe') end |
#key ⇒ Object
23 24 25 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 23 def key fingerprint end |
#to_hash ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 27 def to_hash %i[ external_id external_type fingerprint name url ].index_with do |key| public_send(key) # rubocop:disable GitlabSecurity/PublicSend end end |
#type_identifier? ⇒ Boolean
44 45 46 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 44 def type_identifier? cwe? || wasc? end |
#wasc? ⇒ Boolean
56 57 58 |
# File 'lib/gitlab/ci/reports/security/identifier.rb', line 56 def wasc? external_type.to_s.casecmp?('wasc') end |