1
0
mirror of https://github.com/ko-build/ko.git synced 2025-03-17 20:47:51 +02:00

Don't log the value of --password if given (#458)

This commit is contained in:
Jason Hall 2021-10-01 14:19:26 -04:00 committed by GitHub
parent 688ca47675
commit b9cd759f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,7 +90,7 @@ func addCreate(topLevel *cobra.Command) {
// remaining flags passed after '--'.
argv := []string{"apply", "-f", "-"}
if kflags := kf.Values(); len(kflags) != 0 {
skflags := strings.Join(kflags, " ")
skflags := strings.Join(stripPassword(kflags), " ")
log.Printf(kubectlFlagsWarningTemplate,
"create", skflags,
"create", skflags)
@ -147,3 +147,14 @@ func addCreate(topLevel *cobra.Command) {
topLevel.AddCommand(create)
}
func stripPassword(flags []string) []string {
cp := make([]string, len(flags))
for _, f := range flags {
if strings.HasPrefix(f, "--password=") {
f = "--password=REDACTED"
}
cp = append(cp, f)
}
return cp
}