Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 494: Incomplete string escaping or encoding #204528

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

fkanout
Copy link
Contributor

@fkanout fkanout commented Dec 17, 2024

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

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@fkanout
Copy link
Contributor Author

fkanout commented Dec 17, 2024

Tested locally, it works as expected. And it passes the helper tests.

@fkanout fkanout added v9.0.0 backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) Team:obs-ux-management Observability Management User Experience Team labels Dec 17, 2024
@fkanout fkanout self-assigned this Dec 17, 2024
@fkanout fkanout added the release_note:skip Skip the PR/issue when compiling release notes label Dec 17, 2024
@fkanout fkanout marked this pull request as ready for review December 17, 2024 12:36
@fkanout fkanout requested a review from a team as a code owner December 17, 2024 12:36
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #7 / serverless observability UI Dataset Quality Dataset quality user privileges "before all" hook for "does not show size and last activity columns for underprivileged data stream"

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observability 480.8KB 480.8KB +22.0B

cc @fkanout

@@ -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, "\\'");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test for this helper that fails before this fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maryam-saeidi I have already added a test for this helper in another PR. This PR is security-related only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, really? Thanks for sharing. How does it work if we add a test before having the actual fix? I am not familiar with how the security scanning works.

@fkanout fkanout merged commit cc34e97 into main Dec 17, 2024
17 checks passed
@fkanout fkanout deleted the alert-autofix-494 branch December 17, 2024 16:45
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12377521690

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

stephmilovic pushed a commit that referenced this pull request Dec 17, 2024
…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":"faisal.kanout@elastic.co"},"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 <faisal.kanout@elastic.co>
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Dec 19, 2024
benakansara pushed a commit to benakansara/kibana that referenced this pull request Jan 2, 2025
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 13, 2025
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trends panel does not take filters into account when calculating 'old' stats
5 participants