Welcome to mirror list, hosted at ThFree Co, Russian Federation.

finding_key.rb « security « reports « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0acd923a60f22cd9f33f636e349d6df58628e4ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

module Gitlab
  module Ci
    module Reports
      module Security
        class FindingKey
          def initialize(location_fingerprint:, identifier_fingerprint:)
            @location_fingerprint = location_fingerprint
            @identifier_fingerprint = identifier_fingerprint
          end

          def ==(other)
            has_fingerprints? && other.has_fingerprints? &&
              location_fingerprint == other.location_fingerprint &&
                identifier_fingerprint == other.identifier_fingerprint
          end

          def hash
            location_fingerprint.hash ^ identifier_fingerprint.hash
          end

          alias_method :eql?, :==

          protected

          attr_reader :location_fingerprint, :identifier_fingerprint

          def has_fingerprints?
            location_fingerprint.present? && identifier_fingerprint.present?
          end
        end
      end
    end
  end
end