Module: Mihari::Concerns::FalsePositiveNormalizable

Extended by:
ActiveSupport::Concern
Includes:
MemoWise
Included in:
FalsePositiveValidatable, Rule
Defined in:
lib/mihari/concerns/falsepositive_normalizable.rb

Overview

False positive normalizable concern

Instance Method Summary collapse

Instance Method Details

#normalize_falsepositive(value) ⇒ String, Regexp

Normalize a falsepositive value

Parameters:

  • value (String)

Returns:

  • (String, Regexp)


20
21
22
23
24
25
26
# File 'lib/mihari/concerns/falsepositive_normalizable.rb', line 20

def normalize_falsepositive(value)
  return value if !value.start_with?("/") || !value.end_with?("/")

  # if a value is surrounded by slashes, take it as a regexp
  value_without_slashes = value[1..-2]
  Regexp.compile value_without_slashes.to_s
end