Skip to content

Commit

Permalink
[8.x] Fix code scanning alert no. 494: Incomplete string escaping or …
Browse files Browse the repository at this point in the history
…encoding (#204528) (#204616)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Fix code scanning alert no. 494: Incomplete string escaping or
encoding (#204528)](#204528)

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

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

<!--BACKPORT [{"author":{"name":"Faisal
Kanout","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-17T16:45:16Z","message":"Fix
code scanning alert no. 494: Incomplete string escaping or encoding
(#204528)\n\nFixes\r\n[https://github.com/elastic/kibana/security/code-scanning/494](https://github.com/elastic/kibana/security/code-scanning/494)\r\nFixes
#1311\r\n\r\nEscape first backslash occurrences and all single quotes in
the
`filter`\r\nstring.","sha":"cc34e97de4d2d8a5509eec5e4f9ffcb7338ed54a","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:obs-ux-management"],"title":"Fix
code scanning alert no. 494: Incomplete string escaping or
encoding","number":204528,"url":"https://github.com/elastic/kibana/pull/204528","mergeCommit":{"message":"Fix
code scanning alert no. 494: Incomplete string escaping or encoding
(#204528)\n\nFixes\r\n[https://github.com/elastic/kibana/security/code-scanning/494](https://github.com/elastic/kibana/security/code-scanning/494)\r\nFixes
#1311\r\n\r\nEscape first backslash occurrences and all single quotes in
the
`filter`\r\nstring.","sha":"cc34e97de4d2d8a5509eec5e4f9ffcb7338ed54a"}},"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/204528","number":204528,"mergeCommit":{"message":"Fix
code scanning alert no. 494: Incomplete string escaping or encoding
(#204528)\n\nFixes\r\n[https://github.com/elastic/kibana/security/code-scanning/494](https://github.com/elastic/kibana/security/code-scanning/494)\r\nFixes
#1311\r\n\r\nEscape first backslash occurrences and all single quotes in
the
`filter`\r\nstring.","sha":"cc34e97de4d2d8a5509eec5e4f9ffcb7338ed54a"}}]}]
BACKPORT-->

Co-authored-by: Faisal Kanout <[email protected]>
  • Loading branch information
kibanamachine and fkanout authored Dec 17, 2024
1 parent 5d84fc1 commit 4f1b9b2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getLensOperationFromRuleMetric = (metric: GenericMetric): LensOpera
const { aggType, field, filter = '' } = metric;
let operation: string = aggType;
const operationArgs: string[] = [];
const escapedFilter = filter.replace(/'/g, "\\'");
const escapedFilter = filter.replace(/\\/g, '\\\\').replace(/'/g, "\\'");

if (aggType === Aggregators.RATE) {
return {
Expand Down

0 comments on commit 4f1b9b2

Please sign in to comment.