File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,43 @@ import config from '../../common/config';
2
2
import { getClient } from '../../common/elasticsearch_client' ;
3
3
4
4
5
+ function escapeLuceneSyntax ( str ) {
6
+ return [ ] . map
7
+ . call ( str , char => {
8
+ if (
9
+ char === '/' ||
10
+ char === '+' ||
11
+ char === '-' ||
12
+ char === '&' ||
13
+ char === '|' ||
14
+ char === '!' ||
15
+ char === '(' ||
16
+ char === ')' ||
17
+ char === '{' ||
18
+ char === '}' ||
19
+ char === '[' ||
20
+ char === ']' ||
21
+ char === '^' ||
22
+ char === '"' ||
23
+ char === '~' ||
24
+ char === '*' ||
25
+ char === '?' ||
26
+ char === ':' ||
27
+ char === '\\'
28
+ ) {
29
+ return `\\${ char } ` ;
30
+ }
31
+ return char ;
32
+ } )
33
+ . join ( '' ) ;
34
+ }
35
+
5
36
function getQueryString ( request ) {
6
37
if ( request . params . type === 'elastalert_error' ) {
7
38
return '*:*' ;
8
39
}
9
40
else {
10
- return `rule_name:${ request . query . rule_name || '*' } ` ;
41
+ return `rule_name:" ${ escapeLuceneSyntax ( request . query . rule_name ) || '*' } " ` ;
11
42
}
12
43
}
13
44
You can’t perform that action at this time.
0 commit comments