Skip to content

Commit

Permalink
Fix code scanning alert no. 494: Incomplete string escaping or encodi…
Browse files Browse the repository at this point in the history
…ng (elastic#204528)

Fixes
[https://github.com/elastic/kibana/security/code-scanning/494](https://github.com/elastic/kibana/security/code-scanning/494)
Fixes elastic#1311

Escape first backslash occurrences and all single quotes in the `filter`
string.

(cherry picked from commit cc34e97)
  • Loading branch information
fkanout committed Dec 17, 2024
1 parent 07b2420 commit 2e92f7b
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 2e92f7b

Please sign in to comment.