Merge pull request #7462 from hashicorp/fix_log_secret_filter
make sure we filter the ui as well as the logs
This commit is contained in:
commit
baa43fe78b
|
@ -626,6 +626,9 @@ func TestSensitiveVars(t *testing.T) {
|
|||
if filtered[0] != tc.Expected && len(filtered) != 1 {
|
||||
t.Fatalf("not filtering sensitive vars; filtered is %#v", filtered)
|
||||
}
|
||||
|
||||
// clear filter so it doesn't break other tests
|
||||
LogSecretFilter.s = make(map[string]struct{})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
14
packer/ui.go
14
packer/ui.go
|
@ -247,6 +247,13 @@ func (rw *BasicUi) Message(message string) {
|
|||
rw.l.Lock()
|
||||
defer rw.l.Unlock()
|
||||
|
||||
// Use LogSecretFilter to scrub out sensitive variables
|
||||
for s := range LogSecretFilter.s {
|
||||
if s != "" {
|
||||
message = strings.Replace(message, s, "<sensitive>", -1)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("ui: %s", message)
|
||||
_, err := fmt.Fprint(rw.Writer, message+"\n")
|
||||
if err != nil {
|
||||
|
@ -263,6 +270,13 @@ func (rw *BasicUi) Error(message string) {
|
|||
writer = rw.Writer
|
||||
}
|
||||
|
||||
// Use LogSecretFilter to scrub out sensitive variables
|
||||
for s := range LogSecretFilter.s {
|
||||
if s != "" {
|
||||
message = strings.Replace(message, s, "<sensitive>", -1)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("ui error: %s", message)
|
||||
_, err := fmt.Fprint(writer, message+"\n")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue