Skip to content

Commit

Permalink
[8.x] Fix code scanning alert no. 370: Useless regular-expression cha…
Browse files Browse the repository at this point in the history
…racter escape (#198264) (#198999)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Fix code scanning alert no. 370: Useless regular-expression character
escape (#198264)](#198264)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kfir
Peled","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-05T15:01:20Z","message":"Fix
code scanning alert no. 370: Useless regular-expression character escape
(#198264)\n\nFixes\r\n[https://github.com/elastic/kibana/security/code-scanning/370](https://github.com/elastic/kibana/security/code-scanning/370)\r\n\r\nTo
fix the problem, we need to remove the unnecessary escape
sequence\r\n`\\-` from the regular expression on line 32. This will not
change the\r\nfunctionality of the code but will make the regular
expression clearer\r\nand more maintainable.\r\n\r\n- In general terms,
we need to ensure that only necessary escape\r\nsequences are used in
regular expressions.\r\n- Specifically, we will update the regular
expression on line 32 to\r\nremove the unnecessary escape sequence.\r\n-
The change will be made in the
file\r\n`x-pack/plugins/session_view/public/methods/index.tsx`.\r\n\r\n\r\n_Suggested
fixes powered by Copilot Autofix. Review carefully
before\r\nmerging._\r\n\r\n---------\r\n\r\nCo-authored-by: Copilot
Autofix powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
@Omolola-Akinleye","sha":"ae2b3827f8237a07472699cfbd442a8bc567dc34","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:cloud-deploy"],"title":"Fix
code scanning alert no. 370: Useless regular-expression character
escape","number":198264,"url":"https://github.com/elastic/kibana/pull/198264","mergeCommit":{"message":"Fix
code scanning alert no. 370: Useless regular-expression character escape
(#198264)\n\nFixes\r\n[https://github.com/elastic/kibana/security/code-scanning/370](https://github.com/elastic/kibana/security/code-scanning/370)\r\n\r\nTo
fix the problem, we need to remove the unnecessary escape
sequence\r\n`\\-` from the regular expression on line 32. This will not
change the\r\nfunctionality of the code but will make the regular
expression clearer\r\nand more maintainable.\r\n\r\n- In general terms,
we need to ensure that only necessary escape\r\nsequences are used in
regular expressions.\r\n- Specifically, we will update the regular
expression on line 32 to\r\nremove the unnecessary escape sequence.\r\n-
The change will be made in the
file\r\n`x-pack/plugins/session_view/public/methods/index.tsx`.\r\n\r\n\r\n_Suggested
fixes powered by Copilot Autofix. Review carefully
before\r\nmerging._\r\n\r\n---------\r\n\r\nCo-authored-by: Copilot
Autofix powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
@Omolola-Akinleye","sha":"ae2b3827f8237a07472699cfbd442a8bc567dc34"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198264","number":198264,"mergeCommit":{"message":"Fix
code scanning alert no. 370: Useless regular-expression character escape
(#198264)\n\nFixes\r\n[https://github.com/elastic/kibana/security/code-scanning/370](https://github.com/elastic/kibana/security/code-scanning/370)\r\n\r\nTo
fix the problem, we need to remove the unnecessary escape
sequence\r\n`\\-` from the regular expression on line 32. This will not
change the\r\nfunctionality of the code but will make the regular
expression clearer\r\nand more maintainable.\r\n\r\n- In general terms,
we need to ensure that only necessary escape\r\nsequences are used in
regular expressions.\r\n- Specifically, we will update the regular
expression on line 32 to\r\nremove the unnecessary escape sequence.\r\n-
The change will be made in the
file\r\n`x-pack/plugins/session_view/public/methods/index.tsx`.\r\n\r\n\r\n_Suggested
fixes powered by Copilot Autofix. Review carefully
before\r\nmerging._\r\n\r\n---------\r\n\r\nCo-authored-by: Copilot
Autofix powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
@Omolola-Akinleye","sha":"ae2b3827f8237a07472699cfbd442a8bc567dc34"}}]}]
BACKPORT-->

Co-authored-by: Kfir Peled <[email protected]>
  • Loading branch information
kibanamachine and kfirpeled authored Nov 5, 2024
1 parent 7f99b24 commit f312c1e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions x-pack/plugins/session_view/public/methods/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.*';
Expand Down

0 comments on commit f312c1e

Please sign in to comment.