scrub license keys from all log messages
@@ -9,6 +9,7 @@ import (
"io"
"log"
"os"
+ "regexp"
)
// Logger matches newrelic.Logger to allow implementations to be passed to
@@ -72,8 +73,11 @@ func (f *logFile) fire(level, msg string, ctx map[string]interface{}) {
msg,
ctx,
})
- if nil == err {
- f.l.Print(string(js))
+ if err == nil {
+ // scrub license keys from any portion of the log message
+ re := regexp.MustCompile(`license_key=[a-fA-F0-9]+`)
+ sanitized := re.ReplaceAllLiteralString(string(js), "license_key=[redacted]")
+ f.l.Print(sanitized)
} else {
f.l.Printf("unable to marshal log entry: %v", err)
}
