Skip to content

Commit

Permalink
filter password from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhooker committed Oct 24, 2017
1 parent 84eff2d commit abcc02d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions post-processor/vsphere/post-processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,25 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac

ui.Message(fmt.Sprintf("Uploading %s to vSphere", source))

log.Printf("Starting ovftool with parameters: %s",
strings.Replace(
strings.Join(args, " "),
password,
"<password>",
-1))
log.Printf("Starting ovftool with parameters: %s", p.filterLog(strings.Join(args, " ")))

var out bytes.Buffer
cmd := exec.Command("ovftool", args...)
cmd.Stdout = &out
if err := cmd.Run(); err != nil {
return nil, false, fmt.Errorf("Failed: %s\n%s\n", err, out.String())
return nil, false, fmt.Errorf("Failed: %s\n%s\n", err, p.filterLog(out.String()))
}

ui.Message(out.String())
ui.Message(p.filterLog(out.String()))

return artifact, false, nil
}

func (p *PostProcessor) filterLog(s string) string {
password := url.QueryEscape(p.config.Password)
return strings.Replace(s, password, "<password>", -1)
}

func (p *PostProcessor) BuildArgs(source, ovftool_uri string) ([]string, error) {
args := []string{
"--acceptAllEulas",
Expand Down

0 comments on commit abcc02d

Please sign in to comment.