From d904de7a7746da8ba33d750c17a2be2eb5605d7a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:57:37 +0000 Subject: [PATCH] fix: keep the migration script's mapping lookup inside the mappings directory A project schema read from the source cluster was joined into the mapping file path, so a value such as ../x could select a file outside --mappings. Such a schema now falls back to default_node.json like any unknown schema. Addresses Sonar pythonsecurity:S8707. Co-Authored-By: jason.han --- elastic/scripts/migrate_search_indices.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elastic/scripts/migrate_search_indices.py b/elastic/scripts/migrate_search_indices.py index 76ed14d05..83d4f2650 100755 --- a/elastic/scripts/migrate_search_indices.py +++ b/elastic/scripts/migrate_search_indices.py @@ -144,7 +144,8 @@ def shipped_mapping(source, index, mappings_dir): return load_mapping(mappings_dir, suffix[1:] + ".json") schema = project_schema(source, index[:-len("_node")] + "_metadata") or "default" name = schema + "_node.json" - if not os.path.isfile(os.path.join(mappings_dir, name)): + # The schema comes from the source cluster: it must name a file in the mappings directory itself. + if os.path.basename(name) != name or not os.path.isfile(os.path.join(mappings_dir, name)): print(f" warning: no mapping for schema '{schema}', using default_node.json") name = "default_node.json" return load_mapping(mappings_dir, name)