Skip to content

EQL: changes to strings and regular expressions #61659

@rw-access

Description

@rw-access

Bringing discussion from the 2020-08-27 meeting here

We've talked about changes to the EQL syntax, particularly around quoting (escaping fields: #57194 and #51443). And if we want to make changes to the language, we should do it now while we're experimental.

In EQL, there are four options for quoting literal strings:

  • "using double quotes" which is an escaped string, and requires " to be escaped
  • 'using single quotes' which is an escaped string, and allows for literal "
  • ?"using literal double quotes" which is a raw string, no literal " allowed
  • ?'using literal single quotes' which is a raw string, no literal ' allowed

I did some analysis from our internal repository of EQL rules to breakdown our usage of different types of strings. Almost 98% percent of our strings are in the " form.

type count
" 2389
' 56
?" 21
?' 8

Of those, all usages of ? were used in the match function. There were no other instances of those string types but in regular expressions. If we want to remove three of the four string permutations (keeping "), now seems like right time. Although, I do think it is very convenient to have an option for unescaped strings. Escaping can be cumbersome, and I think an unescaped form of a string would help our users. I don't know if ?" is the ideal form, or if something else is bettter.

For regular expressions, I think that a new syntax could make a lot of sense with our users, and we could better align with Lucene and Javascript syntax, using /.../. I believe a grammar would look like this /([^/\\]|\\/|\\.)*/. This was well received by Intelligence and Analytics team (owners of detection-rules and the EQL rules for Endgame).

If we change the accepted syntax for regular expressions, we need to decide on the appropriate contexts. I think this is the most obvious:

  • match(some.field, /some.regular.expression/)

We could potentially allow these as well, but I can see arguments for and against. I'm not sure where I lean.

  • some.field == /some.regular.expression/ equivalent to the above
  • some.field != /some.regular.expression/ inverse of the above

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions