From 802a0dfdadf414558940cc4747b86160773d33a3 Mon Sep 17 00:00:00 2001 From: Kfir Peled <61654899+kfirpeled@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:01:20 +0000 Subject: [PATCH] Fix code scanning alert no. 370: Useless regular-expression character escape (#198264) Fixes [https://github.com/elastic/kibana/security/code-scanning/370](https://github.com/elastic/kibana/security/code-scanning/370) To fix the problem, we need to remove the unnecessary escape sequence `\-` from the regular expression on line 32. This will not change the functionality of the code but will make the regular expression clearer and more maintainable. - In general terms, we need to ensure that only necessary escape sequences are used in regular expressions. - Specifically, we will update the regular expression on line 32 to remove the unnecessary escape sequence. - The change will be made in the file `x-pack/plugins/session_view/public/methods/index.tsx`. _Suggested fixes powered by Copilot Autofix. Review carefully before merging._ --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: @Omolola-Akinleye --- x-pack/plugins/session_view/public/methods/index.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugins/session_view/public/methods/index.tsx b/x-pack/plugins/session_view/public/methods/index.tsx index ad8d77660b3b1..43295737c21f1 100644 --- a/x-pack/plugins/session_view/public/methods/index.tsx +++ b/x-pack/plugins/session_view/public/methods/index.tsx @@ -28,10 +28,7 @@ const SUPPORTED_PACKAGES = [ CLOUD_DEFEND_DATA_SOURCE, AUDITBEAT_DATA_SOURCE, ]; -const INDEX_REGEX = new RegExp( - `([a-z0-9_-]+\:)?[a-z0-9\-.]*(${SUPPORTED_PACKAGES.join('|')})`, - 'i' -); +const INDEX_REGEX = new RegExp(`([a-z0-9_-]+\:)?[a-z0-9-.]*(${SUPPORTED_PACKAGES.join('|')})`, 'i'); export const DEFAULT_INDEX = 'logs-*'; export const CLOUD_DEFEND_INDEX = 'logs-cloud_defend.*';