Skip to content

Commit a06ea24

Browse files
authored
Fix data stream wildcard resolution bug in eql search api. (#61904)
The eql search api redirects to the search api. For this reason the eql search api could work with concrete data stream names. However if security is enabled and a data stream name snippet with a wildcard was used then it could not resolve this expressions. This is because the EqlSearchRequest class didn't overwrite the `includeDataStreams()` method. This pr fixes this, so that the security layer can properly expand data stream name wildcard expressions for the eql search api. This commit also moves the eql data stream test to xpack rest tests, so that the test runs with security enabled. This is required to reproduce the bug. Closes #60828
1 parent 3dc86ca commit a06ea24

File tree

3 files changed

+69
-72
lines changed

3 files changed

+69
-72
lines changed

x-pack/plugin/eql/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/eql/20_data_streams.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ public Task createTask(long id, String type, String action, TaskId parentTaskId,
375375
return new EqlSearchTask(id, type, action, getDescription(), parentTaskId, headers, null, null, keepAlive);
376376
}
377377

378+
@Override
379+
public boolean includeDataStreams() {
380+
return true;
381+
}
382+
378383
@Override
379384
public String getDescription() {
380385
StringBuilder sb = new StringBuilder();

x-pack/plugin/src/test/resources/rest-api-spec/test/data_stream/10_data_stream_resolvability.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,67 @@
474474
indices.delete_data_stream:
475475
name: simple-data-stream1
476476
- is_true: acknowledged
477+
478+
---
479+
"Verify data stream resolvability in EQL search API":
480+
- skip:
481+
version: " - 7.99.99"
482+
reason: "change to 7.9.1 after backport"
483+
features: allowed_warnings
484+
485+
- do:
486+
allowed_warnings:
487+
- "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation"
488+
indices.put_index_template:
489+
name: my-template1
490+
body:
491+
index_patterns: [simple-data-stream1]
492+
template:
493+
mappings:
494+
properties:
495+
'@timestamp':
496+
type: date
497+
data_stream: {}
498+
499+
- do:
500+
indices.create_data_stream:
501+
name: simple-data-stream1
502+
503+
- do:
504+
bulk:
505+
refresh: true
506+
body:
507+
- create:
508+
_index: simple-data-stream1
509+
_id: 1
510+
- event:
511+
- category: process
512+
"@timestamp": 2020-02-03T12:34:56Z
513+
user: SYSTEM
514+
515+
- do:
516+
eql.search:
517+
index: simple-data-stream1
518+
body:
519+
query: "process where user = 'SYSTEM'"
520+
521+
- match: {timed_out: false}
522+
- match: {hits.total.value: 1}
523+
- match: {hits.total.relation: "eq"}
524+
- match: {hits.events.0._source.user: "SYSTEM"}
525+
526+
- do:
527+
eql.search:
528+
index: simple-data-s*
529+
body:
530+
query: "process where user = 'SYSTEM'"
531+
532+
- match: {timed_out: false}
533+
- match: {hits.total.value: 1}
534+
- match: {hits.total.relation: "eq"}
535+
- match: {hits.events.0._source.user: "SYSTEM"}
536+
537+
- do:
538+
indices.delete_data_stream:
539+
name: simple-data-stream1
540+
- is_true: acknowledged

0 commit comments

Comments
 (0)