mask.go 572 B

12345678910111213141516
  1. // Package mask provides value-masking for env values shown to humans.
  2. // Rule: values of length <= 4 are fully replaced with "***"; longer values
  3. // show their first 4 characters followed by "***".
  4. //
  5. // Values that are `env:VAR` references (parent-env indirections) are NOT
  6. // masked; callers should detect those via config.IsEnvRef and print them
  7. // as-is. This helper intentionally stays unaware of that distinction.
  8. package mask
  9. // Value returns a masked representation of v.
  10. func Value(v string) string {
  11. if len(v) <= 4 {
  12. return "***"
  13. }
  14. return v[:4] + "***"
  15. }