kryptheon 0.1.64 → 0.1.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/kryptheon.js CHANGED
@@ -974,10 +974,19 @@ function writeSpec(relativeFile, source) {
974
974
 
975
975
  // Passwords typed during recording land in the file as plain text. Swap them
976
976
  // for environment variables before the file is left lying around.
977
+ // The passwords already set for this project (KRYPTHEON_PASSWORD_* in .env or
978
+ // the environment): a recording that typed one of them, into a box whose name
979
+ // says nothing, has it taken out too (blind round 30).
980
+ function knownPasswords() {
981
+ const known = Object.assign(Object.create(null), secrets.readEnvFile(secrets.envFileFor(USER_DIR)));
982
+ for (const name of Object.keys(process.env)) if (/^KRYPTHEON_PASSWORD/.test(name)) known[name] = process.env[name];
983
+ return known;
984
+ }
985
+
977
986
  function takeOutSecrets(relativeFile) {
978
987
  const source = readSpec(relativeFile);
979
988
  if (source === null) return [];
980
- const result = replay.scrubSecrets(source);
989
+ const result = replay.scrubSecrets(source, { known: knownPasswords() });
981
990
  if (!result.replacements.length) return [];
982
991
  return writeSpec(relativeFile, result.source) ? result.replacements : [];
983
992
  }
@@ -1894,9 +1903,8 @@ function triageSpecs() {
1894
1903
  // Recordings made before secrets were stripped still hold the real value.
1895
1904
  // Say so rather than rewriting: a spec that works today should keep
1896
1905
  // working until the person has somewhere to put the password.
1897
- if (replay.scrubSecrets(source).replacements.length) {
1898
- withSecrets.push({ name: name, fields: replay.scrubSecrets(source).replacements });
1899
- }
1906
+ const leftIn = replay.scrubSecrets(source, { known: knownPasswords() }).replacements;
1907
+ if (leftIn.length) withSecrets.push({ name: name, fields: leftIn });
1900
1908
 
1901
1909
  // A recording that falls back to an empty password is not run at all. It
1902
1910
  // would sign in blank, fail, and send the reader looking at their app.