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

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

47 lines
1 KiB
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
module Security
class FindingSignature
include VulnerabilityFindingSignatureHelpers
attr_accessor :algorithm_type, :signature_value
def initialize(params = {})
@algorithm_type = params.dig(:algorithm_type)
@signature_value = params.dig(:signature_value)
end
def signature_sha
Digest::SHA1.digest(signature_value)
end
def signature_hex
signature_sha.unpack1("H*")
end
def to_hash
{
algorithm_type: algorithm_type,
signature_sha: signature_sha
}
end
def valid?
algorithm_types.key?(algorithm_type)
end
def eql?(other)
other.algorithm_type == algorithm_type &&
other.signature_sha == signature_sha
end
alias_method :==, :eql?
end
end
end
end
end