Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions eql/functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""EQL functions."""
import re
import fnmatch

from .errors import EqlError
from .signatures import SignatureMixin
Expand Down Expand Up @@ -555,18 +556,9 @@ class Wildcard(FunctionSignature):
def to_regex(cls, *wildcards):
"""Convert a list of wildcards to a regular expression."""
expressions = []
head = "^"
tail = "$"

for wildcard in wildcards:
pieces = [re.escape(p) for p in fold_case(wildcard).split('*')]
regex = head + '.*?'.join(pieces) + tail

tail_skip = '.*?$'

if regex.endswith(tail_skip):
regex = regex[:-len(tail_skip)]
expressions.append(regex)
expressions.append(fnmatch.translate(wildcard))

return "|".join(expressions)

Expand Down