From bbf10833af025c851c84dda5e729bd83a24e867b Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 5 Feb 2023 16:40:26 +0100 Subject: [PATCH] Make secrets redaction case insensitive and add messaging param (#6067) --- cmd/helper.go | 3 ++- push/pushover.go | 4 +++- push/telegram.go | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/helper.go b/cmd/helper.go index bc0be8e5a..95f0f0758 100644 --- a/cmd/helper.go +++ b/cmd/helper.go @@ -56,9 +56,10 @@ func redact(src string) string { "user", "password", "pin", // users "token", "access", "refresh", "accesstoken", "refreshtoken", // tokens, including template variations "ain", "secret", "serial", "deviceid", "machineid", "idtag", // devices + "app", "chats", "recipients", // push messaging "vin"} // vehicles return regexp. - MustCompile(fmt.Sprintf(`\b(%s)\b.*?:.*`, strings.Join(secrets, "|"))). + MustCompile(fmt.Sprintf(`(?i)\b(%s)\b.*?:.*`, strings.Join(secrets, "|"))). ReplaceAllString(src, "$1: *****") } diff --git a/push/pushover.go b/push/pushover.go index e8e570dca..09832b7c1 100644 --- a/push/pushover.go +++ b/push/pushover.go @@ -38,12 +38,14 @@ func NewPushOverFromConfig(other map[string]interface{}) (Messenger, error) { } m := &PushOver{ - log: util.NewLogger("pushover"), + log: util.NewLogger("pushover").Redact(cc.App), app: pushover.New(cc.App), device: strings.Join(cc.Devices, ","), recipients: cc.Recipients, } + m.log.Redact(cc.Recipients...) + return m, nil } diff --git a/push/telegram.go b/push/telegram.go index ac3adea94..234909258 100644 --- a/push/telegram.go +++ b/push/telegram.go @@ -2,6 +2,7 @@ package push import ( "errors" + "strconv" "sync" "github.com/evcc-io/evcc/util" @@ -36,9 +37,13 @@ func NewTelegramFromConfig(other map[string]interface{}) (Messenger, error) { return nil, errors.New("telegram: invalid bot token") } - log := util.NewLogger("telegram") + log := util.NewLogger("telegram").Redact(cc.Token) _ = tgbotapi.SetLogger(log.ERROR) + for _, i := range cc.Chats { + log.Redact(strconv.FormatInt(i, 10)) + } + m := &Telegram{ log: log, bot: bot,