Skip to content

Commit ce51a84

Browse files
[8.19] ES|QL: Disallow brackets in unquoted index patterns (#130427) (#130938) (#130984)
1 parent 086cc99 commit ce51a84

File tree

16 files changed

+2346
-2017
lines changed

16 files changed

+2346
-2017
lines changed

docs/changelog/130427.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 130427
2+
summary: Disallow brackets in unquoted index pattersn
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ METADATA : 'metadata';
300300
// in 8.14 ` were not allowed
301301
// this has been relaxed in 8.15 since " is used for quoting
302302
fragment UNQUOTED_SOURCE_PART
303-
: ~[:"=|,[\]/ \t\r\n]
303+
: ~[:"=|,[\]/() \t\r\n]
304304
| '/' ~[*/] // allow single / but not followed by another / or * which would start a comment -- used in index pattern date spec
305305
;
306306
@@ -400,7 +400,7 @@ ENRICH_WITH : WITH -> type(WITH), pushMode(ENRICH_FIELD_MODE);
400400
// similar to that of an index
401401
// see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#indices-create-api-path-params
402402
fragment ENRICH_POLICY_NAME_BODY
403-
: ~[\\/?"<>| ,#\t\r\n:]
403+
: ~[\\/?"<>| ,#\t\r\n:()]
404404
;
405405

406406
ENRICH_POLICY_NAME
@@ -412,6 +412,8 @@ ENRICH_MODE_UNQUOTED_VALUE
412412
: ENRICH_POLICY_NAME -> type(ENRICH_POLICY_NAME)
413413
;
414414

415+
ENRICH_QUOTED_POLICY_NAME : QUOTED_STRING -> type(QUOTED_STRING);
416+
415417
ENRICH_LINE_COMMENT
416418
: LINE_COMMENT -> channel(HIDDEN)
417419
;

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ showCommand
345345
;
346346

347347
enrichCommand
348-
: ENRICH policyName=ENRICH_POLICY_NAME (ON matchField=qualifiedNamePattern)? (WITH enrichWithClause (COMMA enrichWithClause)*)?
348+
: ENRICH policyName=enrichPolicyName (ON matchField=qualifiedNamePattern)? (WITH enrichWithClause (COMMA enrichWithClause)*)?
349+
;
350+
351+
enrichPolicyName
352+
: ENRICH_POLICY_NAME
353+
| QUOTED_STRING
349354
;
350355

351356
enrichWithClause

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,13 @@ public enum Cap {
10121012
/**
10131013
* Support avg with aggregate metric doubles
10141014
*/
1015-
AGGREGATE_METRIC_DOUBLE_AVG(AGGREGATE_METRIC_DOUBLE_FEATURE_FLAG);
1015+
AGGREGATE_METRIC_DOUBLE_AVG(AGGREGATE_METRIC_DOUBLE_FEATURE_FLAG),
1016+
1017+
/**
1018+
* Forbid usage of brackets in unquoted index and enrich policy names
1019+
* https://github.com/elastic/elasticsearch/issues/130378
1020+
*/
1021+
NO_BRACKETS_IN_UNQUOTED_INDEX_NAMES;
10161022

10171023
private final boolean enabled;
10181024

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.interp

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.java

Lines changed: 1089 additions & 1085 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)