Skip to content

fix: keep the migration script's mapping lookup inside the mappings directory - #294

Open
HuiJun wants to merge 1 commit into
developfrom
fix/migration-script-mapping-path
Open

HuiJun wants to merge 1 commit into
developfrom
fix/migration-script-mapping-path

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

elastic/scripts/migrate_search_indices.py picks a node mapping file as <schema>_node.json inside --mappings, where schema is read from the project's metadata document in the source cluster. A schema such as ../x or an absolute path made shipped_mapping load a file outside the mappings directory and send it to the target cluster as the index mapping. A schema that is not a plain file name is now treated like any unknown schema: a warning, then default_node.json.

Relates to SonarCloud issue AaHncA10_gf8BehZaY6E (pythonsecurity:S8707, migrate_search_indices.py:154). Sonar traces the taint from the --mappings CLI argument. That part is by design (the operator chooses the directory), so the issue may stay open after this change and is then a candidate to mark as accepted; the path this PR closes is the one a person running the script does not control.

Why it is safe

  • The shipped schemas (default, cameo, jupyter, msosa) and any custom schema that is a plain name resolve exactly as before; only names containing a path separator change, and they get the existing fallback.
  • Checked by calling shipped_mapping with a stub source and a temp mappings directory: cameo → cameo_node.json, unknown → default with warning, ../secret and an absolute path → default with warning. On develop the same ../secret call returned the file outside the directory. The script has no test suite in the repo, so this check is not committed.

Quality Assurance opened this PR for Jason
Implemented in session Get SonarCloud analysis landing for exec-mms
Review with Devin · Open in Devin Desktop


…irectory

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 <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant