From 2ed05e4a85cb41a24646b02ee9c1b6ab2b0e9cde Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 20 Nov 2024 04:15:51 +1100 Subject: [PATCH] [7.17] Improves pattern matching for data telemetry (#197876) (#200739) # Backport This will backport the following commits from `main` to `7.17`: - [Improves pattern matching for data telemetry (#197876)](https://github.com/elastic/kibana/pull/197876) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) \n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Christiane (Tina) Heiligers "}},{"branch":"7.17","label":"v7.17.26","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Christiane (Tina) Heiligers --- .../get_data_telemetry/get_data_telemetry.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts index 8a0b86cf3b0f0..1a613b4548d17 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts @@ -114,7 +114,8 @@ function findMatchingDescriptors({ // avoid system indices caught by very fuzzy index patterns (i.e.: *log* would catch `.kibana-log-...`) return false; } - return new RegExp(`^${pattern.replace(/\./g, '\\.').replace(/\*/g, '.*')}$`).test(name); + const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + return new RegExp(`^${escapedPattern.replace(/\\\*/g, '.*')}$`).test(name); }); }