Extensions ignore --use-context and --config-file and get the current context's credentials
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 70/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- cli
Línea de trabajo
Start in the extension dispatch path in src/cli.ts (around lines 341-354), where loadCfg() is called without the parsed --use-context, --config-file or --command-profile values, then follow buildContextEnv in src/extension/context.ts. Compare with the early config sniffing at src/cli.ts:150-206. Done when the reproduction commands print URL=http://b.example:9200 ARGS=x for both flag positions, and tests cover global flags before and after the extension name.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Extensions always receive the env for the config file's current_context, ignoring --use-context and --config-file. The extension dispatch path in src/cli.ts (lines ~341-354) calls loadCfg() with no options, so buildContextEnv (src/extension/context.ts) builds ELASTIC_ES_URL/ELASTIC_ES_API_KEY/etc. from the default context. The early config load at src/cli.ts:150-206 doesn't help here: it sniffs --use-context/--config-file/--command-profile, but extension dispatch never threads those values into loadCfg().
A related symptom: dispatch forwards process.argv.slice(3), so when a global flag comes before the extension name, the flag, its value, and the extension name all get passed to the extension as positional args.
Reproduction
Built dist/cli.js, using a fake HOME so nothing touches the real ~/.elastic:
R=/tmp/a22; mkdir -p $R/home/.elastic $R/ext
printf '#!/bin/sh\necho "URL=$ELASTIC_ES_URL ARGS=$*"\n' > $R/ext/run; chmod +x $R/ext/run
echo "[{\"name\":\"dumpenv\",\"source\":\"local:$R/ext\",\"path\":\"$R/ext\",\"entrypoint\":\"$R/ext/run\"}]" > $R/home/.elastic/extensions.json
cat > $R/cfg.yml <<'Y'
current_context: a
contexts:
a: { elasticsearch: { url: "http://a.example:9200", auth: { api_key: "AAA" } } }
b: { elasticsearch: { url: "http://b.example:9200", auth: { api_key: "BBB" } } }
Y
export HOME=$R/home ELASTIC_CLI_CONFIG_FILE=$R/cfg.yml
node dist/cli.js --use-context b dumpenv x
node dist/cli.js dumpenv --use-context b x
unset ELASTIC_CLI_CONFIG_FILE; node dist/cli.js --config-file $R/cfg.yml dumpenv x
Actual:
URL=http://a.example:9200 ARGS=b dumpenv x
URL=http://a.example:9200 ARGS=--use-context b x
URL= ARGS=/tmp/a22/cfg.yml dumpenv x
Expected: URL=http://b.example:9200 ARGS=x for the first two commands. The third should use cfg.yml and output ARGS=x.
Notes
This is a security concern as well as a correctness one. A user who runs --use-context staging to keep a tool away from prod still hands the extension the prod credentials. The root banner check (earlyConfig.value.banner) isn't part of this bug, because earlyConfig is loaded with the sniffed overrides. Open PR #718 (#700) doesn't change the extension dispatch path.
Acceptance criteria
- Extension dispatch passes the parsed
--use-context,--config-fileand--command-profilevalues toloadConfig, and the extension env reflects the chosen context. - Global flags placed before the extension name are not forwarded to the extension as args.
- Tests cover both flag positions.
Related
#512, #576, #700, #718
authored by Pi Coding Agent (Claude Opus 5.5)
- Lenguaje dominante
- TypeScript
- Estrellas
- 47
- Forks
- 27
- Merge medio
- 2 d 6 h
- PR fusionados (30 d)
- 52
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de elastic/cli
-
feat: ship skills/elastic/SKILL.md for agent invocationPosiblemente ocupada @onatozmenn la tomó hace 15 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
elastic/cli#628 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
elastic/cli#617 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 Medio día Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 20/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de elastic/cli
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/playwright#43327 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/TypeScript#64758 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
opensearch-project/OpenSearch-Dashboards#12937 ·
Los mantenedores suelen responder en 2 días
-
Liveness marks block-included attesters live in the block's epoch instead of the attestation's epochAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
a2ui-project/a2ui#3158 ·
Los mantenedores suelen responder en 2 días