diff --git a/lib/mihari.rb b/lib/mihari.rb index 2655300a5..5d56e226f 100644 --- a/lib/mihari.rb +++ b/lib/mihari.rb @@ -55,6 +55,7 @@ require "mihari/concerns/configurable" require "mihari/concerns/database_connectable" require "mihari/concerns/error_unwrappable" +require "mihari/concerns/falsepositive_normalizable" require "mihari/concerns/falsepositive_validatable" require "mihari/concerns/refangable" require "mihari/concerns/retriable" diff --git a/lib/mihari/concerns/falsepositive_normalizable.rb b/lib/mihari/concerns/falsepositive_normalizable.rb new file mode 100644 index 000000000..5aac3836d --- /dev/null +++ b/lib/mihari/concerns/falsepositive_normalizable.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Mihari + module Concerns + # + # False positive normalizable concern + # + module FalsePositiveNormalizable + extend ActiveSupport::Concern + + prepend MemoWise + + # + # Normalize a falsepositive value + # + # @param [String] value + # + # @return [String, Regexp] + # + 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 + memo_wise :normalize_falsepositive + end + end +end diff --git a/lib/mihari/concerns/falsepositive_validatable.rb b/lib/mihari/concerns/falsepositive_validatable.rb index 405d5b5b4..7a09fbc24 100644 --- a/lib/mihari/concerns/falsepositive_validatable.rb +++ b/lib/mihari/concerns/falsepositive_validatable.rb @@ -8,23 +8,7 @@ module Concerns module FalsePositiveValidatable extend ActiveSupport::Concern - prepend MemoWise - - # - # Normalize a falsepositive value - # - # @param [String] value - # - # @return [String, Regexp] - # - 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 - memo_wise :normalize_falsepositive + include FalsePositiveNormalizable # # Check whether a value is valid format as a disallowed data value