Module: FiberAudit::Correlation::Fingerprint

Defined in:
lib/fiber_audit/correlation/fingerprint.rb

Class Method Summary collapse

Class Method Details

.call(rule_id:, path:, enclosing_symbol:, operation:) ⇒ Object



11
12
13
14
15
# File 'lib/fiber_audit/correlation/fingerprint.rb', line 11

def call(rule_id:, path:, enclosing_symbol:, operation:)
  Digest::SHA256.hexdigest(
    [rule_id, normalize_path(path), enclosing_symbol, operation].join(':')
  )
end

.normalize_path(path) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/fiber_audit/correlation/fingerprint.rb', line 17

def normalize_path(path)
  return '' if path.nil?

  Pathname.new(path).cleanpath.to_s
rescue ArgumentError
  path.to_s
end