Skip to content

Commit d12c047

Browse files
Add support for eql-wildcard and kql-match_only_text (elastic#1583)
* Add support for eql-wildcard and kql-match_only_text * bump kql version * lookup elasticsearch type family prior to getting type hint Co-authored-by: David French <[email protected]>
1 parent 0b57778 commit d12c047

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

detection_rules/ecs.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ class KqlSchema2Eql(eql.Schema):
175175
"keyword": eql.types.TypeHint.String,
176176
"ip": eql.types.TypeHint.String,
177177
"float": eql.types.TypeHint.Numeric,
178-
"double": eql.types.TypeHint.Numeric,
179-
"long": eql.types.TypeHint.Numeric,
180-
"short": eql.types.TypeHint.Numeric,
178+
# "double": eql.types.TypeHint.Numeric,
179+
# "long": eql.types.TypeHint.Numeric,
180+
# "short": eql.types.TypeHint.Numeric,
181+
"integer": eql.types.TypeHint.Numeric,
181182
"boolean": eql.types.TypeHint.Boolean,
182183
}
183184

@@ -191,9 +192,12 @@ def validate_event_type(self, event_type):
191192
return True
192193

193194
def get_event_type_hint(self, event_type, path):
195+
from kql.parser import elasticsearch_type_family
196+
194197
dotted = ".".join(path)
195198
elasticsearch_type = self.kql_schema.get(dotted)
196-
eql_hint = self.type_mapping.get(elasticsearch_type)
199+
es_type_family = elasticsearch_type_family(elasticsearch_type)
200+
eql_hint = self.type_mapping.get(es_type_family)
197201

198202
if eql_hint is not None:
199203
return eql_hint, None

kql/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .kql2eql import KqlToEQL
1414
from .parser import lark_parse, KqlParser
1515

16-
__version__ = '0.1.5'
16+
__version__ = '0.1.6'
1717
__all__ = (
1818
"ast",
1919
"from_eql",

kql/parser.py

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def elasticsearch_type_family(mapping_type: str) -> str:
5858
# text search types
5959
"annotated-text": "text",
6060
"completion": "text",
61+
"match_only_text": "text",
6162
"search-as_you_type": "text",
6263

6364
# keyword

0 commit comments

Comments
 (0)