123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- [[eql-function-ref]]
- == EQL function reference
- ++++
- <titleabbrev>Function reference</titleabbrev>
- ++++
- experimental::[]
- {es} supports the following EQL functions:
- * <<eql-fn-between>>
- * <<eql-fn-endswith>>
- * <<eql-fn-length>>
- * <<eql-fn-startswith>>
- * <<eql-fn-substring>>
- * <<eql-fn-wildcard>>
- [discrete]
- [[eql-fn-between]]
- === `between`
- Extracts a substring that's between a provided `left` and `right` text in a
- source string.
- [%collapsible]
- ====
- *Example*
- [source,eql]
- ----
- // file.path = "C:\\Windows\\System32\\cmd.exe"
- between(file.path, "system32\\\\", ".exe") // returns "cmd"
- between(file.path, "workspace\\\\", ".exe") // returns ""
- // Greedy matching defaults to false.
- between(file.path, "\\\\", "\\\\", false) // returns "Windows"
- // Sets greedy matching to true
- between(file.path, "\\\\", "\\\\", true) // returns "Windows\\System32"
- // Case sensitivity defaults to false.
- between(file.path, "system32\\\\", ".exe", false, false) // returns "cmd"
- // Sets case sensitivity to true
- between(file.path, "system32\\\\", ".exe", false, true) // returns ""
- between(file.path, "System32\\\\", ".exe", false, true) // returns "cmd"
- // empty source string
- between("", "system32\\\\", ".exe") // returns ""
- between("", "", "") // returns ""
- // null handling
- between(null, "system32\\\\", ".exe") // returns null
- ----
- *Syntax*
- [source,txt]
- ----
- between(<source>, <left>, <right>[, <greedy_matching>, <case_sensitive>])
- ----
- *Parameters*
- `<source>`::
- +
- --
- (Required, string or `null`)
- Source string. Empty strings return an empty string (`""`), regardless of the
- `<left>` or `<right>` parameters. If `null`, the function returns `null`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- Fields containing <<array,array values>> use the first array item only.
- --
- `<left>`::
- +
- --
- (Required, string)
- Text to the left of the substring to extract. This text should include
- whitespace.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- <<array,Array values>> are not supported.
- --
- `<right>`::
- +
- --
- (Required, string)
- Text to the right of the substring to extract. This text should include
- whitespace.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- <<array,Array values>> are not supported.
- --
- `<greedy_matching>`::
- (Optional, boolean)
- If `true`, match the longest possible substring, similar to `.*` in regular
- expressions. If `false`, match the shortest possible substring, similar to `.*?`
- in regular expressions. Defaults to `false`.
- `<case_sensitive>`::
- (Optional, boolean)
- If `true`, matching is case-sensitive. Defaults to `false`.
- *Returns:* string or `null`
- ====
- [discrete]
- [[eql-fn-endswith]]
- === `endsWith`
- Returns `true` if a source string ends with a provided substring. Matching is
- case insensitive.
- [%collapsible]
- ====
- *Example*
- [source,eql]
- ----
- endsWith("regsvr32.exe", ".exe") // returns true
- endsWith("regsvr32.exe", ".EXE") // returns true
- endsWith("regsvr32.exe", ".dll") // returns false
- endsWith("", "") // returns true
- // file.name = "regsvr32.exe"
- endsWith(file.name, ".exe") // returns true
- endsWith(file.name, ".dll") // returns false
- // file.extension = ".exe"
- endsWith("regsvr32.exe", file.extension) // returns true
- endsWith("ntdll.dll", file.name) // returns false
- // file.name = [ "ntdll.dll", "regsvr32.exe" ]
- endsWith(file.name, ".dll") // returns true
- endsWith(file.name, ".exe") // returns false
- // null handling
- endsWith("regsvr32.exe", null) // returns null
- endsWith("", null) // returns null
- endsWith(null, ".exe") // returns null
- endsWith(null, null) // returns null
- ----
- *Syntax*
- [source,txt]
- ----
- endsWith(<source>, <substring>)
- ----
- *Parameters*
- `<source>`::
- +
- --
- (Required, string or `null`)
- Source string. If `null`, the function returns `null`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- Fields containing <<array,array values>> use the first array item only.
- --
- `<substring>`::
- +
- --
- (Required, string or `null`)
- Substring to search for. If `null`, the function returns `null`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- --
- *Returns:* boolean or `null`
- ====
- [discrete]
- [[eql-fn-length]]
- === `length`
- Returns the character length of a provided string, including whitespace and
- punctuation.
- [%collapsible]
- ====
- *Example*
- [source,eql]
- ----
- length("explorer.exe") // returns 12
- length("start explorer.exe") // returns 18
- length("") // returns 0
- length(null) // returns null
- // process.name = "regsvr32.exe"
- length(process.name) // returns 12
- ----
- *Syntax*
- [source,txt]
- ----
- length(<string>)
- ----
- *Parameters*
- `<string>`::
- +
- --
- (Required, string or `null`)
- String for which to return the character length. If `null`, the function returns
- `null`. Empty strings return `0`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- <<array,Array values>> are not supported.
- --
- *Returns:* integer or `null`
- ====
- [discrete]
- [[eql-fn-startswith]]
- === `startsWith`
- Returns `true` if a source string begins with a provided substring. Matching is
- case insensitive.
- [%collapsible]
- ====
- *Example*
- [source,eql]
- ----
- startsWith("regsvr32.exe", "regsvr32") // returns true
- startsWith("regsvr32.exe", "RegSvr32") // returns true
- startsWith("regsvr32.exe", "explorer") // returns false
- startsWith("", "") // returns true
- // process.name = "regsvr32.exe"
- startsWith(process.name, "regsvr32") // returns true
- startsWith(process.name, "explorer") // returns false
- // process.name = "regsvr32"
- startsWith("regsvr32.exe", process.name) // returns true
- startsWith("explorer.exe", process.name) // returns false
- // process.name = [ "explorer.exe", "regsvr32.exe" ]
- startsWith(process.name, "explorer") // returns true
- startsWith(process.name, "regsvr32") // returns false
- // null handling
- startsWith("regsvr32.exe", null) // returns null
- startsWith("", null) // returns null
- startsWith(null, "regsvr32") // returns null
- startsWith(null, null) // returns null
- ----
- *Syntax*
- [source,txt]
- ----
- startsWith(<source>, <substring>)
- ----
- *Parameters*
- `<source>`::
- +
- --
- (Required, string or `null`)
- Source string. If `null`, the function returns `null`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- Fields containing <<array,array values>> use the first array item only.
- --
- `<substring>`::
- +
- --
- (Required, string or `null`)
- Substring to search for. If `null`, the function returns `null`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- --
- *Returns:* boolean or `null`
- ====
- [discrete]
- [[eql-fn-substring]]
- === `substring`
- Extracts a substring from a source string at provided start and end positions.
- If no end position is provided, the function extracts the remaining string.
- [%collapsible]
- ====
- *Example*
- [source,eql]
- ----
- substring("start regsvr32.exe", 6) // returns "regsvr32.exe"
- substring("start regsvr32.exe", 0, 5) // returns "start"
- substring("start regsvr32.exe", 6, 14) // returns "regsvr32"
- substring("start regsvr32.exe", -4) // returns ".exe"
- substring("start regsvr32.exe", -4, -1) // returns ".ex"
- ----
- *Syntax*
- [source,txt]
- ----
- substring(<source>, <start_pos>[, <end_pos>])
- ----
- *Parameters*
- `<source>`::
- (Required, string)
- Source string.
- `<start_pos>`::
- +
- --
- (Required, integer)
- Starting position for extraction.
- If this position is higher than the `<end_pos>` position or the length of the
- `<source>` string, the function returns an empty string.
- Positions are zero-indexed. Negative offsets are supported.
- --
- `<end_pos>`::
- (Optional, integer)
- Exclusive end position for extraction. If this position is not provided, the
- function returns the remaining string.
- +
- Positions are zero-indexed. Negative offsets are supported.
- *Returns:* string
- ====
- [discrete]
- [[eql-fn-wildcard]]
- === `wildcard`
- Returns `true` if a source string matches one or more provided wildcard
- expressions.
- [%collapsible]
- ====
- *Example*
- [source,eql]
- ----
- // The two following expressions are equivalent.
- process.name == "*regsvr32*" or process.name == "*explorer*"
- wildcard(process.name, "*regsvr32*", "*explorer*")
- // process.name = "regsvr32.exe"
- wildcard(process.name, "*regsvr32*") // returns true
- wildcard(process.name, "*regsvr32*", "*explorer*") // returns true
- wildcard(process.name, "*explorer*") // returns false
- wildcard(process.name, "*explorer*", "*scrobj*") // returns false
- // empty strings
- wildcard("", "*start*") // returns false
- wildcard("", "*") // returns true
- wildcard("", "") // returns true
- // null handling
- wildcard(null, "*regsvr32*") // returns null
- wildcard(process.name, null) // returns null
- ----
- *Syntax*
- [source,txt]
- ----
- wildcard(<source>, <wildcard_exp>[, ...])
- ----
- *Parameters*
- `<source>`::
- +
- --
- (Required, string)
- Source string. If `null`, the function returns `null`.
- If using a field as the argument, this parameter only supports the following
- field datatypes:
- * <<keyword,`keyword`>>
- * <<constant-keyword,`constant_keyword`>>
- * <<text,`text`>> field with a <<keyword,`keyword`>> or
- <<constant-keyword,`constant_keyword`>> sub-field
- --
- `<wildcard_exp>`::
- +
- --
- (Required{multi-arg}, string)
- Wildcard expression used to match the source string. If `null`, the function
- returns `null`. Fields are not supported as arguments.
- --
- *Returns:* boolean
- ====
|