Skip to content

Commit 71434e6

Browse files
ES|QL: Disallow brackets in unquoted index patterns (elastic#130427)
1 parent 3b3d5ec commit 71434e6

File tree

18 files changed

+2529
-2146
lines changed

18 files changed

+2529
-2146
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/EsqlBaseParser.g4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ showCommand
251251
;
252252

253253
enrichCommand
254-
: ENRICH policyName=ENRICH_POLICY_NAME (ON matchField=qualifiedNamePattern)? (WITH enrichWithClause (COMMA enrichWithClause)*)?
254+
: ENRICH policyName=enrichPolicyName (ON matchField=qualifiedNamePattern)? (WITH enrichWithClause (COMMA enrichWithClause)*)?
255+
;
256+
257+
enrichPolicyName
258+
: ENRICH_POLICY_NAME
259+
| QUOTED_STRING
255260
;
256261

257262
enrichWithClause

x-pack/plugin/esql/src/main/antlr/lexer/Enrich.g4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ENRICH_WITH : WITH -> type(WITH), pushMode(ENRICH_FIELD_MODE);
2424
// similar to that of an index
2525
// see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#indices-create-api-path-params
2626
fragment ENRICH_POLICY_NAME_BODY
27-
: ~[\\/?"<>| ,#\t\r\n:]
27+
: ~[\\/?"<>| ,#\t\r\n:()]
2828
;
2929
3030
ENRICH_POLICY_NAME
@@ -36,6 +36,8 @@ ENRICH_MODE_UNQUOTED_VALUE
3636
: ENRICH_POLICY_NAME -> type(ENRICH_POLICY_NAME)
3737
;
3838
39+
ENRICH_QUOTED_POLICY_NAME : QUOTED_STRING -> type(QUOTED_STRING);
40+
3941
ENRICH_LINE_COMMENT
4042
: LINE_COMMENT -> channel(HIDDEN)
4143
;

x-pack/plugin/esql/src/main/antlr/lexer/From.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ FROM_RP : RP -> type(RP), popMode;
2929
// in 8.14 ` were not allowed
3030
// this has been relaxed in 8.15 since " is used for quoting
3131
fragment UNQUOTED_SOURCE_PART
32-
: ~[:"=|,[\]/ \t\r\n]
32+
: ~[:"=|,[\]/() \t\r\n]
3333
| '/' ~[*/] // allow single / but not followed by another / or * which would start a comment -- used in index pattern date spec
3434
;
3535

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
@@ -1228,7 +1228,13 @@ public enum Cap {
12281228
/**
12291229
* Support avg with aggregate metric doubles
12301230
*/
1231-
AGGREGATE_METRIC_DOUBLE_AVG(AGGREGATE_METRIC_DOUBLE_FEATURE_FLAG);
1231+
AGGREGATE_METRIC_DOUBLE_AVG(AGGREGATE_METRIC_DOUBLE_FEATURE_FLAG),
1232+
1233+
/**
1234+
* Forbid usage of brackets in unquoted index and enrich policy names
1235+
* https://github.com/elastic/elasticsearch/issues/130378
1236+
*/
1237+
NO_BRACKETS_IN_UNQUOTED_INDEX_NAMES;
12321238

12331239
private final boolean enabled;
12341240

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: 1152 additions & 1147 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)