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 Incomplete string escaping or encoding #212847

Merged
merged 1 commit into from
Mar 4, 2025
Merged

Fix Incomplete string escaping or encoding #212847

merged 1 commit into from
Mar 4, 2025

Conversation

bhapas
Copy link
Contributor

@bhapas bhapas commented Mar 3, 2025

Fix for https://github.com/elastic/kibana/security/code-scanning/546

To fix the problem, we need to ensure that backslashes are also escaped in the trim_key and trim_value properties of the kvInput object. This can be done by adding an additional replace call to escape backslashes before escaping single and double quotes. The best way to fix this without changing existing functionality is to use a regular expression with the g flag to replace all occurrences of backslashes with double backslashes.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@bhapas bhapas changed the title Potential fix for code scanning alert no. 546: Incomplete string escaping or encoding Fix Incomplete string escaping or encoding Mar 3, 2025
@bhapas bhapas self-assigned this Mar 3, 2025
@bhapas bhapas added backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) backport:version Backport to applied version labels Feature:AutomaticImport v8.18.1 v8.19.0 release_note:skip Skip the PR/issue when compiling release notes Team:Security-Scalability Team label for Security Integrations Scalability Team labels Mar 3, 2025
@bhapas bhapas marked this pull request as ready for review March 3, 2025 07:54
@bhapas bhapas requested a review from a team as a code owner March 3, 2025 07:54
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-scalability (Team:Security-Scalability)

@bhapas bhapas merged commit 8970b99 into main Mar 4, 2025
24 checks passed
@bhapas bhapas deleted the alert-autofix-546 branch March 4, 2025 12:05
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 4, 2025
Fix for
[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)

To fix the problem, we need to ensure that backslashes are also escaped
in the `trim_key` and `trim_value` properties of the `kvInput` object.
This can be done by adding an additional replace call to escape
backslashes before escaping single and double quotes. The best way to
fix this without changing existing functionality is to use a regular
expression with the `g` flag to replace all occurrences of backslashes
with double backslashes.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
(cherry picked from commit 8970b99)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 4, 2025
Fix for
[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)

To fix the problem, we need to ensure that backslashes are also escaped
in the `trim_key` and `trim_value` properties of the `kvInput` object.
This can be done by adding an additional replace call to escape
backslashes before escaping single and double quotes. The best way to
fix this without changing existing functionality is to use a regular
expression with the `g` flag to replace all occurrences of backslashes
with double backslashes.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
(cherry picked from commit 8970b99)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 4, 2025
Fix for
[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)

To fix the problem, we need to ensure that backslashes are also escaped
in the `trim_key` and `trim_value` properties of the `kvInput` object.
This can be done by adding an additional replace call to escape
backslashes before escaping single and double quotes. The best way to
fix this without changing existing functionality is to use a regular
expression with the `g` flag to replace all occurrences of backslashes
with double backslashes.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
(cherry picked from commit 8970b99)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.18
8.x
9.0

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Mar 4, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [Fix Incomplete string escaping or encoding
(#212847)](#212847)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Bharat
Pasupula","email":"123897612+bhapas@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-04T12:05:05Z","message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Team:Security-Scalability","backport:version","Feature:AutomaticImport","v9.1.0","v8.19.0","v8.18.1"],"title":"Fix
Incomplete string escaping or
encoding","number":212847,"url":"https://github.com/elastic/kibana/pull/212847","mergeCommit":{"message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212847","number":212847,"mergeCommit":{"message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Bharat Pasupula <123897612+bhapas@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Mar 4, 2025
# Backport

This will backport the following commits from `main` to `9.0`:
- [Fix Incomplete string escaping or encoding
(#212847)](#212847)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Bharat
Pasupula","email":"123897612+bhapas@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-04T12:05:05Z","message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Team:Security-Scalability","backport:version","Feature:AutomaticImport","v9.1.0","v8.19.0","v8.18.1"],"title":"Fix
Incomplete string escaping or
encoding","number":212847,"url":"https://github.com/elastic/kibana/pull/212847","mergeCommit":{"message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212847","number":212847,"mergeCommit":{"message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Bharat Pasupula <123897612+bhapas@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Mar 4, 2025
# Backport

This will backport the following commits from `main` to `8.18`:
- [Fix Incomplete string escaping or encoding
(#212847)](#212847)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Bharat
Pasupula","email":"123897612+bhapas@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-04T12:05:05Z","message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Team:Security-Scalability","backport:version","Feature:AutomaticImport","v9.1.0","v8.19.0","v8.18.1"],"title":"Fix
Incomplete string escaping or
encoding","number":212847,"url":"https://github.com/elastic/kibana/pull/212847","mergeCommit":{"message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212847","number":212847,"mergeCommit":{"message":"Fix
Incomplete string escaping or encoding (#212847)\n\nFix
for\n[https://github.com/elastic/kibana/security/code-scanning/546](https://github.com/elastic/kibana/security/code-scanning/546)\n\nTo
fix the problem, we need to ensure that backslashes are also escaped\nin
the `trim_key` and `trim_value` properties of the `kvInput`
object.\nThis can be done by adding an additional replace call to
escape\nbackslashes before escaping single and double quotes. The best
way to\nfix this without changing existing functionality is to use a
regular\nexpression with the `g` flag to replace all occurrences of
backslashes\nwith double backslashes.\n\nCo-authored-by: Copilot Autofix
powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"8970b99d4fa0f411f5896bc426806571119eff2c"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Bharat Pasupula <123897612+bhapas@users.noreply.github.com>
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) backport:version Backport to applied version labels Feature:AutomaticImport release_note:skip Skip the PR/issue when compiling release notes Team:Security-Scalability Team label for Security Integrations Scalability Team v8.18.0 v8.18.1 v8.19.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants