Module: Mihari::Mixins::FalsePositive

Includes:
Memist::Memoizable
Included in:
Analyzers::Rule, Schemas::RuleContract
Defined in:
lib/mihari/mixins/falsepositive.rb

Instance Method Summary collapse

Instance Method Details

#normalize_falsepositive(value) ⇒ String, Regexp

Normalize a falsepositive value

Parameters:

  • value (String)

Returns:

  • (String, Regexp)


15
16
17
18
19
20
21
# File 'lib/mihari/mixins/falsepositive.rb', line 15

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

#valid_falsepositive?(value) ⇒ Boolean

Check whetehr a value is valid format as a disallowed data value

Parameters:

  • value (String)

    Data value

Returns:

  • (Boolean)

    true if it is valid, otherwise false



31
32
33
34
35
36
37
38
# File 'lib/mihari/mixins/falsepositive.rb', line 31

def valid_falsepositive?(value)
  begin
    normalize_falsepositive value
  rescue RegexpError
    return false
  end
  true
end