From c507ef818dba6b999cb85a49c720a24862eca429 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 d6eeac2e20f61..3750b8697f493 100644 --- a/packages/kbn-monaco/scripts/utils/create_autocomplete_definitions.js +++ b/packages/kbn-monaco/scripts/utils/create_autocomplete_definitions.js @@ -36,7 +36,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 332199f45b8ee..80489ccdbc589 100644 --- a/packages/kbn-monaco/src/painless/worker/painless_worker.ts +++ b/packages/kbn-monaco/src/painless/worker/painless_worker.ts @@ -44,7 +44,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,