fix(bonfire): mask secret flag values that start with a dash (WR-11)
This commit is contained in:
@@ -306,8 +306,11 @@ func secretFlag(name string) bool {
|
||||
// tryArgs renders args for the wrong-directory Try line, each preceded by a
|
||||
// space and quoted for a shell. The value of a long flag named like a
|
||||
// secret becomes ***, in the "--flag=value" form and in the "--flag value"
|
||||
// form (the next argument, when it does not start with "-"), so a password
|
||||
// typed on the command line does not reach stderr and CI logs.
|
||||
// form, so a password typed on the command line does not reach stderr and
|
||||
// CI logs. In the "--flag value" form the next argument is masked whatever
|
||||
// its first character (pflag takes "-Xk9" as the value too); only "--"
|
||||
// is left alone. tryArgs cannot see flag types, so a secret-named boolean
|
||||
// flag over-masks the argument after it, which is the safe side.
|
||||
func tryArgs(args []string) string {
|
||||
var b strings.Builder
|
||||
for i := 0; i < len(args); i++ {
|
||||
@@ -324,7 +327,7 @@ func tryArgs(args []string) string {
|
||||
continue
|
||||
}
|
||||
b.WriteString(shellQuote(a))
|
||||
if i+1 < len(args) && !strings.HasPrefix(args[i+1], "-") {
|
||||
if i+1 < len(args) && args[i+1] != "--" {
|
||||
b.WriteString(" ***")
|
||||
i++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user