redacted-secret-names
Intent: a secret read from config or declared in a schema is Redacted.
// ❌ noserviceAccount: Config.schema(NonBlank, "GOOGLE_SERVICE_ACCOUNT_JSON")const Session = Schema.Struct({ userId: UserId, accessToken: Schema.String })
// ✅ yesserviceAccount: Config.schema(Schema.Redacted(NonBlank), "GOOGLE_SERVICE_ACCOUNT_JSON")const Session = Schema.Struct({ userId: UserId, accessToken: Schema.Redacted(Schema.String) })Trigger:
- a literal name read with
Config.*that ends withKEY,SECRET,TOKEN,PASSWORD,CREDENTIAL,CREDENTIALSor_JSON(service account keys often travel as inline JSON), when it does not go throughConfig.Redacted, the v3Config.redacted(also wrapping a config,Config.redacted(Config.string(name))), orConfig.schema(Schema.Redacted…(…), name); - a field of
Schema.Struct({…})orSchema.Class<X>("X")({…})whose name is asecretFieldsentry or ends with it capitalized (passwordmatchesdbPassword), declared with aSchema.*constant such asSchema.String, also through.pipe(…),.check(…),.annotate(…)/.annotations(…)orSchema.optional/optionalKey/optionalWith/NullOr/UndefinedOr/NullishOr, with noSchema.Redacted…along the way.
Exemptions and blind spots: a naming heuristic: secrets with other names slip through, non-secrets with these names must be suppressed. Fields declared with a named schema (accessToken: AccessToken) are not inspected; other constructors (Schema.TaggedClass, Schema.TaggedStruct, …) are not seen. process.env read outside Config: see process-env and process-env-in-effect (effecttsgo).
Why: a Redacted value does not end up in logs or toString.
Options:
secretFields: default["password", "secret", "apiKey", "accessToken", "refreshToken", "idToken"](no generictoken), replaced by the configured list.Confignames are fixed.
Fix: none