Make secrets redaction case insensitive and add messaging param (#6067)
Some checks failed
Release / Demo (push) Has been cancelled
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2023-02-05 16:40:26 +01:00 • committed by GitHub
parent b1478fdd0c
commit bbf10833af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -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: *****")
}

View file

@ -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
}

View file

@ -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,