blob: a225625815b14a44683f8ed6bd67b58c5ca358cf (
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 VulnerabilityFindingSignatureHelpers
extend ActiveSupport::Concern
# If the location object describes a physical location within a file
# (filename + line numbers), the 'location' algorithm_type should be used
# If the location object describes arbitrary data, then the 'hash'
# algorithm_type should be used.
ALGORITHM_TYPES = {
hash: 1,
location: 2,
scope_offset: 3,
scope_offset_compressed: 4
}.with_indifferent_access.freeze
class_methods do
def priority(algorithm_type)
raise ArgumentError, "No priority for #{algorithm_type.inspect}" unless ALGORITHM_TYPES.key?(algorithm_type)
ALGORITHM_TYPES[algorithm_type]
end
def algorithm_types
ALGORITHM_TYPES
end
end
def priority
self.class.priority(algorithm_type)
end
def algorithm_types
self.class.algorithm_types
end
end
|