Make secrets redaction case insensitive and add messaging param (#6067)
Some checks failed
Some checks failed
This commit is contained in:
parent
b1478fdd0c
commit
bbf10833af
3 changed files with 11 additions and 3 deletions
|
|
@ -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: *****")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue