fix(config): refuse secrets or credentials sharing an override env var
Merged
OK
2mo ago+110+110+012345678901234567890123456789-7-7-0123456789
envName(packages/e2e/src/config/secrets.ts:122) uppercases a name and turns every character outsideA-Z0-9into_. Two entries likeapi-keyandapi_keytherefore both readE2E_SECRET_API_KEY, andsvc-a/svc_aboth readE2E_USER_SVC_A_*. Setting the variable to rotate one of them quietly replaced both.resolveSecretsnow groups the names in each namespace by the variable they read, before it reads any values. Any group with more than one entry fails withINVALID_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']andsecrets['svc-a']can still coexist. Punctuation in names is still allowed. The engines'targetNameenv mapping inpackages/web/src/provider.tsandpackages/mobile/src/bindings.tsalready appends a hash, so it does not have this problem. - Docs:
reference/environment.mdx,reference/config.mdx,authentication.mdx, theINVALID_CONFIGrow inreference/errors.mdx, andskills/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 fillssecrets['api-key'],secrets['api_key'],credentials['svc-a']andcredentials['svc_a']into four inputs, and the page reports whether each pair matches. All values are fresh random hex; "rotate" setsE2E_SECRET_API_KEYandE2E_USER_SVC_A_PASSWORD. No value appeared in the output or in.e2e/. - New unit tests in
tests/unit/config.test.tscover 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.
| config | main | this branch |
|---|---|---|
| colliding secrets + credentials, no env | exit 0, passes | exit 2, INVALID_CONFIG naming "svc-a" and "svc_a" |
| colliding secrets + credentials, rotate | exit 1, page shows keys same, passwords same | exit 2, INVALID_CONFIG |
| colliding secrets only, no env | exit 0, passes | exit 2, INVALID_CONFIG naming "api-key" and "api_key" |
| colliding secrets only, rotate | exit 1, keys same | exit 2, INVALID_CONFIG |
control (api-key-b, svc-b), rotate | - | exit 0, passes (the rotation changes only its own entry) |