Skip to content
Merged
Changes from 6 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
60 changes: 60 additions & 0 deletions docs/reference/eql/functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ experimental::[]
* <<eql-fn-length>>
* <<eql-fn-startswith>>
* <<eql-fn-string>>
* <<eql-fn-stringcontains>>
* <<eql-fn-substring>>
* <<eql-fn-wildcard>>

Expand Down Expand Up @@ -482,6 +483,65 @@ If using a field as the argument, this parameter does not support the
*Returns:* string or `null`
====

[discrete]
[[eql-fn-stringcontains]]
=== `stringContains`

Returns `true` if a source string contains a provided substring.

[%collapsible]
====
*Example*
[source,eql]
----
// process.command_line = "start regsvr32.exe"
stringContains(process.command_line, "regsvr32") // returns true
stringContains(process.command_line, "start ") // returns true
stringContains(process.command_line, "explorer") // returns false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add one additional example, to show a less obvious usage: stringContains(process.path, process.name).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added with 5ccc198. Thanks!


// empty strings
stringContains("", "") // returns false
stringContains(process.command_line, "") // returns false

// null handling
stringContains(null, "regsvr32") // returns null
Copy link
Contributor

@rw-access rw-access Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based off the conversation today, null in any required input will lead to a null output

Suggested change
stringContains(null, "regsvr32") // returns null
stringContains(null, "regsvr32") // returns null
stringContains(process.command_line, null) // returns null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Updated with 8bcb8f8.

stringContains(process.command_line, null) // returns null
----

*Syntax*
[source,txt]
----
stringContains(<source>, <substring>)
----

*Parameters*
`<source>`::
(Required, string or `null`)
Source string to search. If `null`, the function returns `null`.

If using a field as the argument, this parameter supports only the following
field datatypes:

* <<keyword,`keyword`>>
* <<constant-keyword,`constant_keyword`>>
* <<text,`text`>> field with a <<keyword,`keyword`>> or
<<constant-keyword,`constant_keyword`>> sub-field

`<substring>`::
(Required, string or `null`)
Substring to search for. If `null`, the function returns `null`.

If using a field as the argument, this parameter supports only 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`
Expand Down