debian-mirror-gitlab/lib/gitlab/ci/reports/security/scanner.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.4 KiB
Ruby
Raw Normal View History

2021-09-30 23:02:18 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
module Security
class Scanner
ANALYZER_ORDER = {
"bundler_audit" => 1,
2022-10-11 01:57:18 +05:30
"retire.js" => 2,
2021-09-30 23:02:18 +05:30
"gemnasium" => 3,
"gemnasium-maven" => 3,
"gemnasium-python" => 3,
"bandit" => 1,
2022-06-21 17:19:12 +05:30
"spotbugs" => 1,
2022-10-11 01:57:18 +05:30
"semgrep" => 2
2021-09-30 23:02:18 +05:30
}.freeze
2022-11-25 23:54:43 +05:30
attr_accessor :external_id, :name, :vendor, :version, :primary_identifiers
2021-09-30 23:02:18 +05:30
alias_method :key, :external_id
2022-11-25 23:54:43 +05:30
def initialize(external_id:, name:, vendor:, version:, primary_identifiers: nil)
2021-09-30 23:02:18 +05:30
@external_id = external_id
@name = name
@vendor = vendor
@version = version
2022-11-25 23:54:43 +05:30
@primary_identifiers = primary_identifiers
2021-09-30 23:02:18 +05:30
end
def to_hash
{
external_id: external_id.to_s,
name: name.to_s,
vendor: vendor.presence
}.compact
end
def ==(other)
other.external_id == external_id
end
def <=>(other)
sort_keys.compact <=> other.sort_keys.compact
end
protected
def sort_keys
@sort_keys ||= [order, external_id, name, vendor]
end
private
def order
ANALYZER_ORDER.fetch(external_id, Float::INFINITY)
end
end
end
end
end
end