Skip to content

Commit

Permalink
fixing secret mask bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Feb 18, 2022
1 parent 786296f commit 5848867
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion executor/linux/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,11 @@ func getSecretValues(ctn *pipeline.Container) []string {
secretValues := []string{}
// gather secrets' values from the environment map for masking
for _, secret := range ctn.Secrets {
s := ctn.Environment[strings.ToUpper(secret.Target)]
// capture secret from environment
s, ok := ctn.Environment[strings.ToUpper(secret.Target)]
if !ok {
continue
}
// handle multi line secrets from files
s = strings.ReplaceAll(s, "\n", " ")

Expand Down
4 changes: 4 additions & 0 deletions executor/linux/step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ func TestLinux_getSecretValues(t *testing.T) {
Source: "someOtherSource",
Target: "secret_password",
},
{
Source: "disallowedSecret",
Target: "cannot_find",
},
},
},
},
Expand Down

0 comments on commit 5848867

Please sign in to comment.