-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split falsepositve concern
- Loading branch information
Showing
3 changed files
with
32 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters