Skip to content

Commit 8be400b

Browse files
authored
EQL: Forbid usage of ['] for string literals (elastic#62458)
The usage of single quotes to wrap a string literal is forbidden and an error encouraging the user to user double quotes is returned. Tests are properly adjusted. Relates to elastic#61659
1 parent e1882cd commit 8be400b

File tree

19 files changed

+327
-325
lines changed

19 files changed

+327
-325
lines changed

x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/stats/RestEqlUsageTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void testEqlRestUsage() throws IOException {
178178
" [process where serial_event_id < 4] by exit_code" +
179179
" [process where opcode == 1] by user" +
180180
" [process where opcode == 2] by user" +
181-
" [file where parent_process_name == 'file_delete_event'] by exit_code" +
181+
" [file where parent_process_name == \\\"file_delete_event\\\"] by exit_code" +
182182
" until [process where opcode=1] by ppid" +
183183
" | head 4" +
184184
" | tail 2");
@@ -216,7 +216,7 @@ public void testEqlRestUsage() throws IOException {
216216
runEql("sequence by user, ppid, exit_code with maxspan=1m" +
217217
" [process where serial_event_id < 4]" +
218218
" [process where opcode == 1]" +
219-
" [file where parent_process_name == 'file_delete_event']" +
219+
" [file where parent_process_name == \\\"file_delete_event\\\"]" +
220220
" [process where serial_event_id < 4]" +
221221
" [process where opcode == 1]" +
222222
"| tail 4");

x-pack/plugin/eql/qa/common/src/main/resources/additional_test_queries.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ network where cidrMatch(source_address, "0.0.0.0/0") == true
6262
name = "concatEquals1"
6363
description = "test string concatenation. update test to avoid case-sensitivity issues"
6464
query = '''
65-
process where concat(serial_event_id, '::', process_name, '::', opcode) == '5::wininit.exe::3'
65+
process where concat(serial_event_id, "::", process_name, "::", opcode) == "5::wininit.exe::3"
6666
'''
6767
expected_event_ids = [5]
6868

@@ -138,24 +138,24 @@ expected_event_ids = [98]
138138
notes = "regexp doesn't support character classes"
139139
query = '''
140140
//
141-
// ?'.*?net1\s+localgroup.*?')
142-
process where match(command_line, ?'.*?net1[ ]+localgroup.*?')
141+
// ?".*?net1\s+localgroup.*?")
142+
process where match(command_line, ?".*?net1[ ]+localgroup.*?")
143143
'''
144144

145145
[[queries]]
146146
name = "matchLiteAdditional"
147147
expected_event_ids = [98]
148148
query = '''
149-
process where matchLite(command_line, ?'.*?net1.*?')
149+
process where matchLite(command_line, ?".*?net1.*?")
150150
'''
151151

152152
[[queries]]
153153
name = "matchWithCharacterClasses2"
154154
expected_event_ids = [98]
155155
notes = "regexp doesn't support predefined character classes (like \\s)"
156156
query = '''
157-
// ?'.*?net1\s+\w{4,15}\s+.*?'
158-
process where match(command_line, ?'.*?net1[ ]+[a-z]{4,15}[ ]+.*?')
157+
// ?".*?net1\s+\w{4,15}\s+.*?"
158+
process where match(command_line, ?".*?net1[ ]+[a-z]{4,15}[ ]+.*?")
159159
'''
160160

161161

@@ -164,14 +164,14 @@ process where match(command_line, ?'.*?net1[ ]+[a-z]{4,15}[ ]+.*?')
164164
name = "multiPatternMatch"
165165
expected_event_ids = [50, 97, 98]
166166
query = '''
167-
process where match(command_line, '.*?net[1]? localgroup.*?', '.*? myappserver.py .*?')
167+
process where match(command_line, ".*?net[1]? localgroup.*?", ".*? myappserver.py .*?")
168168
'''
169169

170170
[[queries]]
171171
name = "matchWithSubstring"
172172
expected_event_ids = [50, 98]
173173
query = '''
174-
process where match(substring(command_line, 5), '.*?net[1]? localgroup.*?', '.*? myappserver.py .*?')
174+
process where match(substring(command_line, 5), ".*?net[1]? localgroup.*?", ".*? myappserver.py .*?")
175175
'''
176176

177177
[[queries]]

0 commit comments

Comments
 (0)