CodeQL: Ignore go/log-injection for terminal logger (#44481)

This commit is contained in:
Marcus Efraimsson 2022-01-27 19:01:59 +01:00 committed by GitHub
parent 5721933e4b
commit a23900c4ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -47,9 +47,9 @@ func (l terminalLogger) Log(keyvals ...interface{}) error {
b := &bytes.Buffer{}
lvl := strings.ToUpper(r.level.String())
if r.color > 0 {
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %s ", r.color, lvl, r.time.Format(termTimeFormat), r.msg)
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %s ", r.color, lvl, r.time.Format(termTimeFormat), r.msg) // lgtm[go/log-injection]
} else {
fmt.Fprintf(b, "[%s] [%s] %s ", lvl, r.time.Format(termTimeFormat), r.msg)
fmt.Fprintf(b, "[%s] [%s] %s ", lvl, r.time.Format(termTimeFormat), r.msg) // lgtm[go/log-injection]
}
// try to justify the log output for short messages
@ -160,7 +160,7 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int) {
// XXX: we should probably check that all of your key bytes aren't invalid
if color > 0 {
fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=%s", color, k, v)
fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=%s", color, k, v) // lgtm[go/log-injection]
} else {
buf.WriteString(k)
buf.WriteByte('=')