diagnostics: properly redact endpoints

This commit is contained in:
Matthew Penner 2022-01-20 09:12:24 -07:00
parent a6b77a31dc
commit 6d8c1d2225
No known key found for this signature in database
GPG Key ID: 31311906AD4CF6D6

View File

@ -179,6 +179,17 @@ func diagnosticsCmdRun(cmd *cobra.Command, args []string) {
fmt.Fprintln(output, "Logs redacted.")
}
if !diagnosticsArgs.IncludeEndpoints {
s := output.String()
output.Reset()
s = strings.ReplaceAll(s, cfg.PanelLocation, "{redacted}")
s = strings.ReplaceAll(s, cfg.Api.Host, "{redacted}")
s = strings.ReplaceAll(s, cfg.Api.Ssl.CertificateFile, "{redacted}")
s = strings.ReplaceAll(s, cfg.Api.Ssl.KeyFile, "{redacted}")
s = strings.ReplaceAll(s, cfg.System.Sftp.Address, "{redacted}")
output.WriteString(s)
}
fmt.Println("\n--------------- generated report ---------------")
fmt.Println(output.String())
fmt.Print("--------------- end of report ---------------\n\n")
@ -188,16 +199,6 @@ func diagnosticsCmdRun(cmd *cobra.Command, args []string) {
survey.AskOne(&survey.Confirm{Message: "Upload to " + diagnosticsArgs.HastebinURL + "?", Default: false}, &upload)
}
if upload {
if !diagnosticsArgs.IncludeEndpoints {
s := output.String()
output.Reset()
a := strings.ReplaceAll(cfg.PanelLocation, s, "{redacted}")
a = strings.ReplaceAll(cfg.Api.Host, a, "{redacted}")
a = strings.ReplaceAll(cfg.Api.Ssl.CertificateFile, a, "{redacted}")
a = strings.ReplaceAll(cfg.Api.Ssl.KeyFile, a, "{redacted}")
a = strings.ReplaceAll(cfg.System.Sftp.Address, a, "{redacted}")
output.WriteString(a)
}
u, err := uploadToHastebin(diagnosticsArgs.HastebinURL, output.String())
if err == nil {
fmt.Println("Your report is available here: ", u)