fix(config): refuse secrets or credentials sharing an override env var

Merged
OK
2mo ago
+110-7
  • envName (packages/e2e/src/config/secrets.ts:122) uppercases a name and turns every character outside A-Z0-9 into _. Two entries like api-key and api_key therefore both read E2E_SECRET_API_KEY, and svc-a/svc_a both read E2E_USER_SVC_A_*. Setting the variable to rotate one of them quietly replaced both.
  • resolveSecrets now groups the names in each namespace by the variable they read, before it reads any values. Any group with more than one entry fails with INVALID_CONFIG, whether or not the variable is set. The message names the entries and the variable, never a value.
  • Credentials and secrets are checked separately: their prefixes differ, so credentials['svc-a'] and secrets['svc-a'] can still coexist. Punctuation in names is still allowed. The engines' targetName env mapping in packages/web/src/provider.ts and packages/mobile/src/bindings.ts already appends a hash, so it does not have this problem.
  • Docs: reference/environment.mdx, reference/config.mdx, authentication.mdx, the INVALID_CONFIG row in reference/errors.mdx, and skills/e2e/references/{setup,writing-tests}.md.
ERROR  configuration error INVALID_CONFIG (config)
secrets "api-key" and "api_key" share the override variable E2E_SECRET_API_KEY, so one value set there would replace all of them; rename all but one

Verified

Ran it locally: yes

  • Scratch project at /tmp/oskar-fix-secret-env-collisions: the built CLI (node node_modules/e2e/dist/cli/bin.js run --no-cache) running against a static page. The test fills secrets['api-key'], secrets['api_key'], credentials['svc-a'] and credentials['svc_a'] into four inputs, and the page reports whether each pair matches. All values are fresh random hex; "rotate" sets E2E_SECRET_API_KEY and E2E_USER_SVC_A_PASSWORD. No value appeared in the output or in .e2e/.
  • New unit tests in tests/unit/config.test.ts cover a collision in each namespace (with and without the variable set), groups of 3, providers, error text that leaves out values, and a control case with no collision.
configmainthis branch
colliding secrets + credentials, no envexit 0, passesexit 2, INVALID_CONFIG naming "svc-a" and "svc_a"
colliding secrets + credentials, rotateexit 1, page shows keys same, passwords sameexit 2, INVALID_CONFIG
colliding secrets only, no envexit 0, passesexit 2, INVALID_CONFIG naming "api-key" and "api_key"
colliding secrets only, rotateexit 1, keys sameexit 2, INVALID_CONFIG
control (api-key-b, svc-b), rotate-exit 0, passes (the rotation changes only its own entry)

Devin Review