From a358b174a4d236c3927277719ac8590a571507de Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 3 Apr 2019 10:43:41 -0700 Subject: [PATCH 1/2] make sure we filter the ui as well as the logs --- packer/ui.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packer/ui.go b/packer/ui.go index 0e803efd9..2ee866d2b 100644 --- a/packer/ui.go +++ b/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, "", -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, "", -1) + } + } + log.Printf("ui error: %s", message) _, err := fmt.Fprint(writer, message+"\n") if err != nil { From c1960840e3528bd760b82d8dfbf737d7908b9358 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 3 Apr 2019 11:01:52 -0700 Subject: [PATCH 2/2] fix tests --- packer/core_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packer/core_test.go b/packer/core_test.go index 1d6c87e4c..a2ad81cf4 100644 --- a/packer/core_test.go +++ b/packer/core_test.go @@ -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{}) } }