@@ -28,6 +28,15 @@ const (
2828 BaseJSONOverhead = 50
2929)
3030
31+ // defaultSecretSuffixes contains the default suffixes that identify secret environment variables
32+ var defaultSecretSuffixes = []string {
33+ "_SECRET" ,
34+ "_SECRET_KEY" ,
35+ "_PASSWORD" ,
36+ "_TOKEN" ,
37+ "_ACCESS_KEY" ,
38+ }
39+
3140// Client represents interaction with AWS S3
3241type Client interface {
3342 Bucket () string
@@ -171,13 +180,7 @@ func getEnvs(conf Config, results chan<- getResult) {
171180}
172181
173182func getSecrets (conf Config , results chan <- getResult ) {
174- suffixes := append (conf .SecretSuffixes , []string {
175- "_SECRET" ,
176- "_SECRET_KEY" ,
177- "_PASSWORD" ,
178- "_TOKEN" ,
179- "_ACCESS_KEY" ,
180- }... )
183+ suffixes := append (conf .SecretSuffixes , defaultSecretSuffixes ... )
181184
182185 prefixes := []string {
183186 "secret-files" ,
@@ -271,8 +274,8 @@ func handleEnvs(conf *Config, results <-chan getResult) error {
271274 if err != nil {
272275 log .Printf ("Warning: failed to parse env file %s/%s: %v" , r .bucket , r .key , err )
273276 } else {
274- for _ , value := range envMap {
275- if len (value ) > 0 {
277+ for key , value := range envMap {
278+ if isSecretVar ( key ) && len (value ) > 0 {
276279 redactSecret (conf , value )
277280 }
278281 }
@@ -374,6 +377,16 @@ func handleSecrets(conf *Config, results <-chan getResult) error {
374377 return nil
375378}
376379
380+ // isSecretVar checks if an environment variable name contains any of the secret suffixes
381+ func isSecretVar (key string ) bool {
382+ for _ , suffix := range defaultSecretSuffixes {
383+ if strings .Contains (key , suffix ) {
384+ return true
385+ }
386+ }
387+ return false
388+ }
389+
377390type getResult struct {
378391 bucket string
379392 key string
0 commit comments