Files
DeepSeek-Reasonix/scripts
YHH 8675031b19 fix(config): stop tests reading the developer's real credentials (#7290)
Closes #2419.

RunWithIsolatedUserState redirects HOME, USERPROFILE, XDG_* and AppData, which
covers every location addressed by a path. The OS keyring is not one of those:
it is per-user and has no environment variable in front of it, so legacy
credential migration walked straight past the sandbox into the real store.

On a machine with credentials saved, TestMigrateImportsLegacyStateHomeDotEnv-
Credentials fails by printing the developer's actual API key where its own
fixture was expected. On a clean CI runner the keyring is empty, so it passes —
the suite only breaks for people who use the tool they are working on, which is
why the failing package in #2419 stayed unexplained for two months.

Substituting the lookup once in TestMain makes isolation the default for the
package; the three cases that exercise the lookup already install their own.

Two things verify it, because they fail in different places:

  scripts/credential-leak-check.mjs runs the suite and flags any credential
  printed that appears nowhere in the repo's sources — a value the tests did not
  write can only have come from the machine. It reported one leak before this
  change and none after, and it is the only check that can observe the bug at
  all, since it needs a populated keyring.

  TestKeyringLookupStaysOutOfTheRealStore asserts the substitution itself, so it
  holds on an empty CI keyring where the leak is invisible. Removing the
  substitution turns it red.

Neither prints a credential; the tool reports a SHA-256 prefix and the guard
reports a byte count.
2026-08-03 17:03:43 +08:00
..