From 38d6143f722459002f5556a9f7888ada4193b12d Mon Sep 17 00:00:00 2001
From: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
Date: Wed, 18 Sep 2024 16:45:59 +0100
Subject: [PATCH] [Index Management] Restrict dot-prefixed index patterns in
template form (#193196)
Closes https://github.com/elastic/kibana/issues/190251
## Summary
This PR adds validation that restricts creating a template with a
dot-prefixed index pattern.
Note: I tried adding tests for this validation
[here](https://github.com/elastic/kibana/blob/6a3adf73dacaeda073674ac4a10e8a2597e67739/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx#L163),
but it didn't work because the index pattern field is mocked in the
tests and errors are not triggered from invalid values.
---
.../template_form/template_form_schemas.tsx | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/x-pack/plugins/index_management/public/application/components/template_form/template_form_schemas.tsx b/x-pack/plugins/index_management/public/application/components/template_form/template_form_schemas.tsx
index dec31faad794a..5448c932d65e0 100644
--- a/x-pack/plugins/index_management/public/application/components/template_form/template_form_schemas.tsx
+++ b/x-pack/plugins/index_management/public/application/components/template_form/template_form_schemas.tsx
@@ -129,6 +129,18 @@ export const schemas: Record = {
type: VALIDATION_TYPES.ARRAY_ITEM,
isBlocking: false,
},
+ {
+ validator: startsWithField({
+ char: '.',
+ message: i18n.translate(
+ 'xpack.idxMgmt.templateValidation.indexPatternDotPrefixedError',
+ {
+ defaultMessage: 'Index patterns cannot match dot-prefixed indices.',
+ }
+ ),
+ }),
+ type: VALIDATION_TYPES.ARRAY_ITEM,
+ },
],
},
doCreateDataStream: {