From 51cba4e90c71659c1f0a683f4fb6b254ef00a006 Mon Sep 17 00:00:00 2001 From: "Eyo O. Eyo" <7893459+eokoneyo@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:57:22 +0200 Subject: [PATCH] [CodeQL] resolve issue with incomplete string escaping (#196678) ## Summary Relates to https://github.com/elastic/kibana-team/issues/1102 Particularly addresses issues with incomplete string escaping. Co-authored-by: Elastic Machine (cherry picked from commit 5fb1e127ad0c25b198a97753cbf53f8d714cb2ef) --- .../kbn-monaco/scripts/utils/create_autocomplete_definitions.js | 2 +- packages/kbn-monaco/src/painless/worker/painless_worker.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kbn-monaco/scripts/utils/create_autocomplete_definitions.js b/packages/kbn-monaco/scripts/utils/create_autocomplete_definitions.js index 8b85379838dd4..cf466efba5f42 100644 --- a/packages/kbn-monaco/scripts/utils/create_autocomplete_definitions.js +++ b/packages/kbn-monaco/scripts/utils/create_autocomplete_definitions.js @@ -35,7 +35,7 @@ const getDisplayName = (name, imported) => { displayName = name.split('.').pop() || name; } - return displayName.replace('$', '.'); + return displayName.replace(/^\$/g, '.'); }; /** diff --git a/packages/kbn-monaco/src/painless/worker/painless_worker.ts b/packages/kbn-monaco/src/painless/worker/painless_worker.ts index 9b93d704e3748..c4e9384d6d5e0 100644 --- a/packages/kbn-monaco/src/painless/worker/painless_worker.ts +++ b/packages/kbn-monaco/src/painless/worker/painless_worker.ts @@ -43,7 +43,7 @@ export class PainlessWorker implements BaseWorkerDefinition { fields?: PainlessAutocompleteField[] ): PainlessCompletionResult { // Array of the active line words, e.g., [boolean, isTrue, =, true] - const words = currentLineChars.replace('\t', '').split(' '); + const words = currentLineChars.replace(/\t/g, '').split(/\s/); const autocompleteSuggestions: PainlessCompletionResult = getAutocompleteSuggestions( context,