functions.asciidoc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. [[eql-function-ref]]
  2. == EQL function reference
  3. ++++
  4. <titleabbrev>Function reference</titleabbrev>
  5. ++++
  6. experimental::[]
  7. {es} supports the following EQL functions:
  8. * <<eql-fn-between>>
  9. * <<eql-fn-cidrmatch>>
  10. * <<eql-fn-concat>>
  11. * <<eql-fn-endswith>>
  12. * <<eql-fn-indexof>>
  13. * <<eql-fn-length>>
  14. * <<eql-fn-match>>
  15. * <<eql-fn-startswith>>
  16. * <<eql-fn-string>>
  17. * <<eql-fn-stringcontains>>
  18. * <<eql-fn-substring>>
  19. * <<eql-fn-wildcard>>
  20. [discrete]
  21. [[eql-fn-between]]
  22. === `between`
  23. Extracts a substring that's between a provided `left` and `right` text in a
  24. source string.
  25. [%collapsible]
  26. ====
  27. *Example*
  28. [source,eql]
  29. ----
  30. // file.path = "C:\\Windows\\System32\\cmd.exe"
  31. between(file.path, "system32\\\\", ".exe") // returns "cmd"
  32. between(file.path, "workspace\\\\", ".exe") // returns ""
  33. // Greedy matching defaults to false.
  34. between(file.path, "\\\\", "\\\\", false) // returns "Windows"
  35. // Sets greedy matching to true
  36. between(file.path, "\\\\", "\\\\", true) // returns "Windows\\System32"
  37. // Case sensitivity defaults to false.
  38. between(file.path, "system32\\\\", ".exe", false, false) // returns "cmd"
  39. // Sets case sensitivity to true
  40. between(file.path, "system32\\\\", ".exe", false, true) // returns ""
  41. between(file.path, "System32\\\\", ".exe", false, true) // returns "cmd"
  42. // empty source string
  43. between("", "system32\\\\", ".exe") // returns ""
  44. between("", "", "") // returns ""
  45. // null handling
  46. between(null, "system32\\\\", ".exe") // returns null
  47. ----
  48. *Syntax*
  49. [source,txt]
  50. ----
  51. between(<source>, <left>, <right>[, <greedy_matching>, <case_sensitive>])
  52. ----
  53. *Parameters*
  54. `<source>`::
  55. +
  56. --
  57. (Required, string or `null`)
  58. Source string. Empty strings return an empty string (`""`), regardless of the
  59. `<left>` or `<right>` parameters. If `null`, the function returns `null`.
  60. If using a field as the argument, this parameter supports only the following
  61. field datatypes:
  62. * <<keyword,`keyword`>>
  63. * <<constant-keyword,`constant_keyword`>>
  64. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  65. <<constant-keyword,`constant_keyword`>> sub-field
  66. Fields containing <<array,array values>> use the first array item only.
  67. --
  68. `<left>`::
  69. +
  70. --
  71. (Required, string)
  72. Text to the left of the substring to extract. This text should include
  73. whitespace.
  74. If using a field as the argument, this parameter supports only the following
  75. field datatypes:
  76. * <<keyword,`keyword`>>
  77. * <<constant-keyword,`constant_keyword`>>
  78. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  79. <<constant-keyword,`constant_keyword`>> sub-field
  80. <<array,Array values>> are not supported.
  81. --
  82. `<right>`::
  83. +
  84. --
  85. (Required, string)
  86. Text to the right of the substring to extract. This text should include
  87. whitespace.
  88. If using a field as the argument, this parameter supports only the following
  89. field datatypes:
  90. * <<keyword,`keyword`>>
  91. * <<constant-keyword,`constant_keyword`>>
  92. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  93. <<constant-keyword,`constant_keyword`>> sub-field
  94. <<array,Array values>> are not supported.
  95. --
  96. `<greedy_matching>`::
  97. (Optional, boolean)
  98. If `true`, match the longest possible substring, similar to `.*` in regular
  99. expressions. If `false`, match the shortest possible substring, similar to `.*?`
  100. in regular expressions. Defaults to `false`.
  101. `<case_sensitive>`::
  102. (Optional, boolean)
  103. If `true`, matching is case-sensitive. Defaults to `false`.
  104. *Returns:* string or `null`
  105. ====
  106. [discrete]
  107. [[eql-fn-cidrmatch]]
  108. === `cidrMatch`
  109. Returns `true` if an IP address is contained in one or more provided
  110. https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing[CIDR] blocks.
  111. [%collapsible]
  112. ====
  113. *Example*
  114. [source,eql]
  115. ----
  116. // source.address = "192.168.152.12"
  117. cidrMatch(source.address, "192.168.0.0/16") // returns true
  118. cidrMatch(source.address, "192.168.0.0/16", "10.0.0.0/8") // returns true
  119. cidrMatch(source.address, "10.0.0.0/8") // returns false
  120. cidrMatch(source.address, "10.0.0.0/8", "10.128.0.0/9") // returns false
  121. // null handling
  122. cidrMatch(null, "10.0.0.0/8") // returns null
  123. cidrMatch(source.address, null) // returns null
  124. ----
  125. *Syntax*
  126. [source,txt]
  127. ----
  128. `cidrMatch(<ip_address>, <cidr_block>[, ...])`
  129. ----
  130. *Parameters*
  131. `<ip_address>`::
  132. (Required, string or `null`)
  133. IP address. Supports
  134. https://en.wikipedia.org/wiki/IPv4[IPv4] and
  135. https://en.wikipedia.org/wiki/IPv6[IPv6] addresses. If `null`, the function
  136. returns `null`.
  137. +
  138. If using a field as the argument, this parameter supports only the <<ip,`ip`>>
  139. field datatype.
  140. `<cidr_block>`::
  141. (Required{multi-arg}, string or `null`)
  142. CIDR block you wish to search. If `null`, the function returns `null`.
  143. *Returns:* boolean or `null`
  144. ====
  145. [discrete]
  146. [[eql-fn-concat]]
  147. === `concat`
  148. Returns a concatenated string of provided values.
  149. [%collapsible]
  150. ====
  151. *Example*
  152. [source,eql]
  153. ----
  154. concat("process is ", "regsvr32.exe") // returns "process is regsvr32.exe"
  155. concat("regsvr32.exe", " ", 42) // returns "regsvr32.exe 42"
  156. concat("regsvr32.exe", " ", 42.5) // returns "regsvr32.exe 42.5"
  157. concat("regsvr32.exe", " ", true) // returns "regsvr32.exe true"
  158. concat("regsvr32.exe") // returns "regsvr32.exe"
  159. // process.name = "regsvr32.exe"
  160. concat(process.name, " ", 42) // returns "regsvr32.exe 42"
  161. concat(process.name, " ", 42.5) // returns "regsvr32.exe 42.5"
  162. concat("process is ", process.name) // returns "process is regsvr32.exe"
  163. concat(process.name, " ", true) // returns "regsvr32.exe true"
  164. concat(process.name) // returns "regsvr32.exe"
  165. // process.arg_count = 4
  166. concat(process.name, " ", process.arg_count) // returns "regsvr32.exe 4"
  167. // null handling
  168. concat(null, "regsvr32.exe") // returns null
  169. concat(process.name, null) // returns null
  170. concat(null) // returns null
  171. ----
  172. *Syntax*
  173. [source,txt]
  174. ----
  175. concat(<value>[, <value>])
  176. ----
  177. *Parameters*
  178. `<value>`::
  179. (Required{multi-arg-ref})
  180. Value to concatenate. If any of the arguments are `null`, the function returns `null`.
  181. +
  182. If using a field as the argument, this parameter does not support the
  183. <<text,`text`>> field datatype.
  184. *Returns:* string or `null`
  185. ====
  186. [discrete]
  187. [[eql-fn-endswith]]
  188. === `endsWith`
  189. Returns `true` if a source string ends with a provided substring.
  190. [%collapsible]
  191. ====
  192. *Example*
  193. [source,eql]
  194. ----
  195. endsWith("regsvr32.exe", ".exe") // returns true
  196. endsWith("regsvr32.exe", ".dll") // returns false
  197. endsWith("", "") // returns true
  198. // file.name = "regsvr32.exe"
  199. endsWith(file.name, ".exe") // returns true
  200. endsWith(file.name, ".dll") // returns false
  201. // file.extension = ".exe"
  202. endsWith("regsvr32.exe", file.extension) // returns true
  203. endsWith("ntdll.dll", file.name) // returns false
  204. // file.name = [ "ntdll.dll", "regsvr32.exe" ]
  205. endsWith(file.name, ".dll") // returns true
  206. endsWith(file.name, ".exe") // returns false
  207. // null handling
  208. endsWith("regsvr32.exe", null) // returns null
  209. endsWith("", null) // returns null
  210. endsWith(null, ".exe") // returns null
  211. endsWith(null, null) // returns null
  212. ----
  213. *Syntax*
  214. [source,txt]
  215. ----
  216. endsWith(<source>, <substring>)
  217. ----
  218. *Parameters*
  219. `<source>`::
  220. +
  221. --
  222. (Required, string or `null`)
  223. Source string. If `null`, the function returns `null`.
  224. If using a field as the argument, this parameter supports only the following
  225. field datatypes:
  226. * <<keyword,`keyword`>>
  227. * <<constant-keyword,`constant_keyword`>>
  228. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  229. <<constant-keyword,`constant_keyword`>> sub-field
  230. Fields containing <<array,array values>> use the first array item only.
  231. --
  232. `<substring>`::
  233. +
  234. --
  235. (Required, string or `null`)
  236. Substring to search for. If `null`, the function returns `null`.
  237. If using a field as the argument, this parameter supports only the following
  238. field datatypes:
  239. * <<keyword,`keyword`>>
  240. * <<constant-keyword,`constant_keyword`>>
  241. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  242. <<constant-keyword,`constant_keyword`>> sub-field
  243. --
  244. *Returns:* boolean or `null`
  245. ====
  246. [discrete]
  247. [[eql-fn-indexof]]
  248. === `indexOf`
  249. Returns the first position of a provided substring in a source string.
  250. If an optional start position is provided, this function returns the first
  251. occurrence of the substring at or after the start position.
  252. [%collapsible]
  253. ====
  254. *Example*
  255. [source,eql]
  256. ----
  257. // url.domain = "subdomain.example.com"
  258. indexOf(url.domain, ".") // returns 9
  259. indexOf(url.domain, ".", 9) // returns 9
  260. indexOf(url.domain, ".", 10) // returns 17
  261. indexOf(url.domain, ".", -6) // returns 9
  262. // empty strings
  263. indexOf("", "") // returns 0
  264. indexOf(url.domain, "") // returns 0
  265. indexOf(url.domain, "", 9) // returns 9
  266. indexOf(url.domain, "", 10) // returns 10
  267. indexOf(url.domain, "", -6) // returns 0
  268. // missing substrings
  269. indexOf(url.domain, "z") // returns null
  270. indexOf(url.domain, "z", 9) // returns null
  271. // start position is higher than string length
  272. indexOf(url.domain, ".", 30) // returns null
  273. // null handling
  274. indexOf(null, ".", 9) // returns null
  275. indexOf(url.domain, null, 9) // returns null
  276. indexOf(url.domain, ".", null) // returns null
  277. ----
  278. *Syntax*
  279. [source,txt]
  280. ----
  281. indexOf(<source>, <substring>[, <start_pos>])
  282. ----
  283. *Parameters*
  284. `<source>`::
  285. +
  286. --
  287. (Required, string or `null`)
  288. Source string. If `null`, the function returns `null`.
  289. If using a field as the argument, this parameter supports only the following
  290. field datatypes:
  291. * <<keyword,`keyword`>>
  292. * <<constant-keyword,`constant_keyword`>>
  293. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  294. <<constant-keyword,`constant_keyword`>> sub-field
  295. --
  296. `<substring>`::
  297. +
  298. --
  299. (Required, string or `null`)
  300. Substring to search for.
  301. If this argument is `null` or the `<source>` string does not contain this
  302. substring, the function returns `null`.
  303. If the `<start_pos>` is positive, empty strings (`""`) return the `<start_pos>`.
  304. Otherwise, empty strings return `0`.
  305. If using a field as the argument, this parameter supports only the following
  306. field datatypes:
  307. * <<keyword,`keyword`>>
  308. * <<constant-keyword,`constant_keyword`>>
  309. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  310. <<constant-keyword,`constant_keyword`>> sub-field
  311. --
  312. `<start_pos>`::
  313. +
  314. --
  315. (Optional, integer or `null`)
  316. Starting position for matching. The function will not return positions before
  317. this one. Defaults to `0`.
  318. Positions are zero-indexed. Negative offsets are treated as `0`.
  319. If this argument is `null` or higher than the length of the `<source>` string,
  320. the function returns `null`.
  321. If using a field as the argument, this parameter supports only the following
  322. <<number,numeric>> field datatypes:
  323. * `long`
  324. * `integer`
  325. * `short`
  326. * `byte`
  327. --
  328. *Returns:* integer or `null`
  329. ====
  330. [discrete]
  331. [[eql-fn-length]]
  332. === `length`
  333. Returns the character length of a provided string, including whitespace and
  334. punctuation.
  335. [%collapsible]
  336. ====
  337. *Example*
  338. [source,eql]
  339. ----
  340. length("explorer.exe") // returns 12
  341. length("start explorer.exe") // returns 18
  342. length("") // returns 0
  343. length(null) // returns null
  344. // process.name = "regsvr32.exe"
  345. length(process.name) // returns 12
  346. ----
  347. *Syntax*
  348. [source,txt]
  349. ----
  350. length(<string>)
  351. ----
  352. *Parameters*
  353. `<string>`::
  354. +
  355. --
  356. (Required, string or `null`)
  357. String for which to return the character length. If `null`, the function returns
  358. `null`. Empty strings return `0`.
  359. If using a field as the argument, this parameter supports only the following
  360. field datatypes:
  361. * <<keyword,`keyword`>>
  362. * <<constant-keyword,`constant_keyword`>>
  363. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  364. <<constant-keyword,`constant_keyword`>> sub-field
  365. <<array,Array values>> are not supported.
  366. --
  367. *Returns:* integer or `null`
  368. ====
  369. [discrete]
  370. [[eql-fn-match]]
  371. === `match`
  372. Returns `true` if a source string matches one or more provided regular
  373. expressions.
  374. [%collapsible]
  375. ====
  376. *Example*
  377. [source,eql]
  378. ----
  379. match("explorer.exe", "[a-z]*?.exe") // returns true
  380. match("explorer.exe", "[a-z]*?.exe", "[1-9]") // returns true
  381. match("explorer.exe", "[1-9]") // returns false
  382. match("explorer.exe", "") // returns false
  383. // process.name = "explorer.exe"
  384. match(process.name, "[a-z]*?.exe") // returns true
  385. match(process.name, "[a-z]*?.exe", "[1-9]") // returns true
  386. match(process.name, "[1-9]") // returns false
  387. match(process.name, "") // returns false
  388. // null handling
  389. match(null, "[a-z]*?.exe") // returns null
  390. ----
  391. *Syntax*
  392. [source,txt]
  393. ----
  394. match(<source>, <reg_exp>[, ...])
  395. ----
  396. *Parameters*
  397. `<source>`::
  398. +
  399. --
  400. (Required, string or `null`)
  401. Source string. If `null`, the function returns `null`.
  402. If using a field as the argument, this parameter supports only the following
  403. field datatypes:
  404. * <<keyword,`keyword`>>
  405. * <<constant-keyword,`constant_keyword`>>
  406. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  407. <<constant-keyword,`constant_keyword`>> sub-field
  408. --
  409. `<reg_exp>`::
  410. +
  411. --
  412. (Required{multi-arg-ref}, string)
  413. Regular expression used to match the source string. For supported syntax, see
  414. <<regexp-syntax>>.
  415. https://docs.oracle.com/javase/tutorial/essential/regex/pre_char_classes.html[Predefined
  416. character classes] are not supported.
  417. Fields are not supported as arguments.
  418. --
  419. *Returns:* boolean or `null`
  420. ====
  421. [discrete]
  422. [[eql-fn-startswith]]
  423. === `startsWith`
  424. Returns `true` if a source string begins with a provided substring.
  425. [%collapsible]
  426. ====
  427. *Example*
  428. [source,eql]
  429. ----
  430. startsWith("regsvr32.exe", "regsvr32") // returns true
  431. startsWith("regsvr32.exe", "explorer") // returns false
  432. startsWith("", "") // returns true
  433. // process.name = "regsvr32.exe"
  434. startsWith(process.name, "regsvr32") // returns true
  435. startsWith(process.name, "explorer") // returns false
  436. // process.name = "regsvr32"
  437. startsWith("regsvr32.exe", process.name) // returns true
  438. startsWith("explorer.exe", process.name) // returns false
  439. // process.name = [ "explorer.exe", "regsvr32.exe" ]
  440. startsWith(process.name, "explorer") // returns true
  441. startsWith(process.name, "regsvr32") // returns false
  442. // null handling
  443. startsWith("regsvr32.exe", null) // returns null
  444. startsWith("", null) // returns null
  445. startsWith(null, "regsvr32") // returns null
  446. startsWith(null, null) // returns null
  447. ----
  448. *Syntax*
  449. [source,txt]
  450. ----
  451. startsWith(<source>, <substring>)
  452. ----
  453. *Parameters*
  454. `<source>`::
  455. +
  456. --
  457. (Required, string or `null`)
  458. Source string. If `null`, the function returns `null`.
  459. If using a field as the argument, this parameter supports only the following
  460. field datatypes:
  461. * <<keyword,`keyword`>>
  462. * <<constant-keyword,`constant_keyword`>>
  463. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  464. <<constant-keyword,`constant_keyword`>> sub-field
  465. Fields containing <<array,array values>> use the first array item only.
  466. --
  467. `<substring>`::
  468. +
  469. --
  470. (Required, string or `null`)
  471. Substring to search for. If `null`, the function returns `null`.
  472. If using a field as the argument, this parameter supports only the following
  473. field datatypes:
  474. * <<keyword,`keyword`>>
  475. * <<constant-keyword,`constant_keyword`>>
  476. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  477. <<constant-keyword,`constant_keyword`>> sub-field
  478. --
  479. *Returns:* boolean or `null`
  480. ====
  481. [discrete]
  482. [[eql-fn-string]]
  483. === `string`
  484. Converts a value to a string.
  485. [%collapsible]
  486. ====
  487. *Example*
  488. [source,eql]
  489. ----
  490. string(42) // returns "42"
  491. string(42.5) // returns "42.5"
  492. string("regsvr32.exe") // returns "regsvr32.exe"
  493. string(true) // returns "true"
  494. // null handling
  495. string(null) // returns null
  496. ----
  497. *Syntax*
  498. [source,txt]
  499. ----
  500. string(<value>)
  501. ----
  502. *Parameters*
  503. `<value>`::
  504. (Required)
  505. Value to convert to a string. If `null`, the function returns `null`.
  506. +
  507. If using a field as the argument, this parameter does not support the
  508. <<text,`text`>> field datatype.
  509. *Returns:* string or `null`
  510. ====
  511. [discrete]
  512. [[eql-fn-stringcontains]]
  513. === `stringContains`
  514. Returns `true` if a source string contains a provided substring.
  515. [%collapsible]
  516. ====
  517. *Example*
  518. [source,eql]
  519. ----
  520. // process.command_line = "start regsvr32.exe"
  521. stringContains(process.command_line, "regsvr32") // returns true
  522. stringContains(process.command_line, "start ") // returns true
  523. stringContains(process.command_line, "explorer") // returns false
  524. // process.name = "regsvr32.exe"
  525. stringContains(command_line, process.name) // returns true
  526. // empty strings
  527. stringContains("", "") // returns false
  528. stringContains(process.command_line, "") // returns false
  529. // null handling
  530. stringContains(null, "regsvr32") // returns null
  531. stringContains(process.command_line, null) // returns null
  532. ----
  533. *Syntax*
  534. [source,txt]
  535. ----
  536. stringContains(<source>, <substring>)
  537. ----
  538. *Parameters*
  539. `<source>`::
  540. (Required, string or `null`)
  541. Source string to search. If `null`, the function returns `null`.
  542. If using a field as the argument, this parameter supports only the following
  543. field datatypes:
  544. * <<keyword,`keyword`>>
  545. * <<constant-keyword,`constant_keyword`>>
  546. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  547. <<constant-keyword,`constant_keyword`>> sub-field
  548. `<substring>`::
  549. (Required, string or `null`)
  550. Substring to search for. If `null`, the function returns `null`.
  551. If using a field as the argument, this parameter supports only the following
  552. field datatypes:
  553. * <<keyword,`keyword`>>
  554. * <<constant-keyword,`constant_keyword`>>
  555. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  556. <<constant-keyword,`constant_keyword`>> sub-field
  557. *Returns:* boolean or `null`
  558. ====
  559. [discrete]
  560. [[eql-fn-substring]]
  561. === `substring`
  562. Extracts a substring from a source string at provided start and end positions.
  563. If no end position is provided, the function extracts the remaining string.
  564. [%collapsible]
  565. ====
  566. *Example*
  567. [source,eql]
  568. ----
  569. substring("start regsvr32.exe", 6) // returns "regsvr32.exe"
  570. substring("start regsvr32.exe", 0, 5) // returns "start"
  571. substring("start regsvr32.exe", 6, 14) // returns "regsvr32"
  572. substring("start regsvr32.exe", -4) // returns ".exe"
  573. substring("start regsvr32.exe", -4, -1) // returns ".ex"
  574. ----
  575. *Syntax*
  576. [source,txt]
  577. ----
  578. substring(<source>, <start_pos>[, <end_pos>])
  579. ----
  580. *Parameters*
  581. `<source>`::
  582. (Required, string)
  583. Source string.
  584. `<start_pos>`::
  585. +
  586. --
  587. (Required, integer)
  588. Starting position for extraction.
  589. If this position is higher than the `<end_pos>` position or the length of the
  590. `<source>` string, the function returns an empty string.
  591. Positions are zero-indexed. Negative offsets are supported.
  592. --
  593. `<end_pos>`::
  594. (Optional, integer)
  595. Exclusive end position for extraction. If this position is not provided, the
  596. function returns the remaining string.
  597. +
  598. Positions are zero-indexed. Negative offsets are supported.
  599. *Returns:* string
  600. ====
  601. [discrete]
  602. [[eql-fn-wildcard]]
  603. === `wildcard`
  604. Returns `true` if a source string matches one or more provided wildcard
  605. expressions.
  606. [%collapsible]
  607. ====
  608. *Example*
  609. [source,eql]
  610. ----
  611. // The two following expressions are equivalent.
  612. process.name == "*regsvr32*" or process.name == "*explorer*"
  613. wildcard(process.name, "*regsvr32*", "*explorer*")
  614. // process.name = "regsvr32.exe"
  615. wildcard(process.name, "*regsvr32*") // returns true
  616. wildcard(process.name, "*regsvr32*", "*explorer*") // returns true
  617. wildcard(process.name, "*explorer*") // returns false
  618. wildcard(process.name, "*explorer*", "*scrobj*") // returns false
  619. // empty strings
  620. wildcard("", "*start*") // returns false
  621. wildcard("", "*") // returns true
  622. wildcard("", "") // returns true
  623. // null handling
  624. wildcard(null, "*regsvr32*") // returns null
  625. wildcard(process.name, null) // returns null
  626. ----
  627. *Syntax*
  628. [source,txt]
  629. ----
  630. wildcard(<source>, <wildcard_exp>[, ...])
  631. ----
  632. *Parameters*
  633. `<source>`::
  634. +
  635. --
  636. (Required, string)
  637. Source string. If `null`, the function returns `null`.
  638. If using a field as the argument, this parameter supports only the following
  639. field datatypes:
  640. * <<keyword,`keyword`>>
  641. * <<constant-keyword,`constant_keyword`>>
  642. * <<text,`text`>> field with a <<keyword,`keyword`>> or
  643. <<constant-keyword,`constant_keyword`>> sub-field
  644. --
  645. `<wildcard_exp>`::
  646. +
  647. --
  648. (Required{multi-arg-ref}, string)
  649. Wildcard expression used to match the source string. If `null`, the function
  650. returns `null`. Fields are not supported as arguments.
  651. --
  652. *Returns:* boolean
  653. ====