Class: Gitlab::Ci::Reports::Security::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/security/scanner.rb

Constant Summary collapse

ANALYZER_ORDER =
{
  "bundler_audit" => 1,
  "retire.js" => 2,
  "gemnasium" => 3,
  "gemnasium-maven" => 3,
  "gemnasium-python" => 3,
  "bandit" => 1,
  "spotbugs" => 1,
  "semgrep" => 2
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(external_id:, name:, vendor:, version:, primary_identifiers: nil) ⇒ Scanner

Returns a new instance of Scanner.



23
24
25
26
27
28
29
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 23

def initialize(external_id:, name:, vendor:, version:, primary_identifiers: nil)
  @external_id = external_id
  @name = name
  @vendor = vendor
  @version = version
  @primary_identifiers = primary_identifiers
end

Instance Attribute Details

#external_idObject Also known as: key

Returns the value of attribute external_id.



19
20
21
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 19

def external_id
  @external_id
end

#nameObject

Returns the value of attribute name.



19
20
21
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 19

def name
  @name
end

#primary_identifiersObject

Returns the value of attribute primary_identifiers.



19
20
21
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 19

def primary_identifiers
  @primary_identifiers
end

#vendorObject

Returns the value of attribute vendor.



19
20
21
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 19

def vendor
  @vendor
end

#versionObject

Returns the value of attribute version.



19
20
21
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 19

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



43
44
45
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 43

def <=>(other)
  sort_keys.compact <=> other.sort_keys.compact
end

#==(other) ⇒ Object



39
40
41
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 39

def ==(other)
  other.external_id == external_id
end

#to_hashObject



31
32
33
34
35
36
37
# File 'lib/gitlab/ci/reports/security/scanner.rb', line 31

def to_hash
  {
    external_id: external_id.to_s,
    name: name.to_s,
    vendor: vendor.presence
  }.compact
end