From a80bacaf3f502d8cb6b1991cb5c97b1a45c754bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Aug 2026 07:43:18 +0000 Subject: [PATCH] Bump github.com/sirupsen/logrus from 1.10.0 to 1.10.1 Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.10.0 to 1.10.1. - [Release notes](https://github.com/sirupsen/logrus/releases) - [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md) - [Commits](https://github.com/sirupsen/logrus/compare/v1.10.0...v1.10.1) --- updated-dependencies: - dependency-name: github.com/sirupsen/logrus dependency-version: 1.10.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../github.com/sirupsen/logrus/CHANGELOG.md | 8 +++ vendor/github.com/sirupsen/logrus/entry.go | 60 +++++++------------ vendor/github.com/sirupsen/logrus/exported.go | 2 +- .../sirupsen/logrus/text_formatter.go | 28 ++++++++- vendor/modules.txt | 2 +- 7 files changed, 61 insertions(+), 45 deletions(-) diff --git a/go.mod b/go.mod index 2f8202682..c80664e8b 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/google/uuid v1.6.0 github.com/opencontainers/selinux v1.15.1 github.com/prometheus/procfs v0.21.1 - github.com/sirupsen/logrus v1.10.0 + github.com/sirupsen/logrus v1.10.1 github.com/stretchr/testify v1.12.0 github.com/urfave/cli/v2 v2.27.7 golang.org/x/mod v0.40.0 diff --git a/go.sum b/go.sum index f56ecd3e1..7c3ee51aa 100644 --- a/go.sum +++ b/go.sum @@ -94,8 +94,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.10.0 h1:T8MxJJXVZkfcC5zSRMRAg2F8+lxjmUCGGWPzFxO+Msc= -github.com/sirupsen/logrus v1.10.0/go.mod h1:FXZFonkDAnFozmO+5hGAFvB0Yg9/j2SIhA/QuIkP180= +github.com/sirupsen/logrus v1.10.1 h1:xi4336Zh11WpU14fXR6I67V3yaTPQYwRx2WEtHbRg4Q= +github.com/sirupsen/logrus v1.10.1/go.mod h1:vsQHnG7xzNsxk3NrwboUiWPnIC3dmbjcGPykD7+tiHk= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/vendor/github.com/sirupsen/logrus/CHANGELOG.md b/vendor/github.com/sirupsen/logrus/CHANGELOG.md index 650f64988..3e6675633 100644 --- a/vendor/github.com/sirupsen/logrus/CHANGELOG.md +++ b/vendor/github.com/sirupsen/logrus/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## 1.10.1 + +Fixes: + + * Fix a regression introduced in v1.10.0 where `TextFormatter` could panic + when formatting nil or panicking `error` and `fmt.Stringer` values. + * Allow function-backed implementations of `error` as field values. + ## 1.10.0 Fixes: diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go index 1cb4b5204..82de41f9f 100644 --- a/vendor/github.com/sirupsen/logrus/entry.go +++ b/vendor/github.com/sirupsen/logrus/entry.go @@ -159,15 +159,7 @@ func (entry *Entry) String() (string, error) { // WithError adds an error as single field (using the key defined in [ErrorKey]) // to the Entry. func (entry *Entry) WithError(err error) *Entry { - // Avoid reflection work in WithFields; we know the type is an error; - // copy the entry data and set the ErrorKey directly. - dup := entry.dup() - dup.Data = maps.Clone(entry.Data) - if dup.Data == nil { - dup.Data = make(Fields, 1) - } - dup.Data[ErrorKey] = err - return dup + return entry.WithField(ErrorKey, err) } // WithContext adds a context to the Entry. @@ -182,18 +174,7 @@ func (entry *Entry) WithContext(ctx context.Context) *Entry { func (entry *Entry) WithField(key string, value any) *Entry { dup := entry.dup() dup.Data = maps.Clone(entry.Data) - if isInvalidField(value) { - if dup.err != "" { - dup.err += ", skipping unsupported field " + strconv.Quote(key) - } else { - dup.err = "skipping unsupported field " + strconv.Quote(key) - } - return dup - } - if dup.Data == nil { - dup.Data = make(Fields, 1) - } - dup.Data[key] = value + dup.addField(key, value) return dup } @@ -204,27 +185,11 @@ func (entry *Entry) WithFields(fields Fields) *Entry { maps.Copy(dup.Data, entry.Data) for key, value := range fields { - if isInvalidField(value) { - if dup.err != "" { - dup.err += ", skipping unsupported field " + strconv.Quote(key) - } else { - dup.err = "skipping unsupported field " + strconv.Quote(key) - } - } else { - dup.Data[key] = value - } + dup.addField(key, value) } return dup } -func isInvalidField(v any) bool { - t := reflect.TypeOf(v) - if t == nil { - return false - } - return t.Kind() == reflect.Func || t.Kind() == reflect.Pointer && t.Elem().Kind() == reflect.Func -} - // WithTime overrides the time of the Entry. func (entry *Entry) WithTime(t time.Time) *Entry { dup := entry.dup() @@ -233,6 +198,25 @@ func (entry *Entry) WithTime(t time.Time) *Entry { return dup } +func (entry *Entry) addField(key string, value any) { + if _, ok := value.(error); !ok { + t := reflect.TypeOf(value) + if t != nil && (t.Kind() == reflect.Func || t.Kind() == reflect.Pointer && t.Elem().Kind() == reflect.Func) { + if entry.err != "" { + entry.err += ", skipping unsupported field " + strconv.Quote(key) + } else { + entry.err = "skipping unsupported field " + strconv.Quote(key) + } + return + } + } + + if entry.Data == nil { + entry.Data = make(Fields, 1) + } + entry.Data[key] = value +} + // getPackageName reduces a fully qualified function name to the package name // There really ought to be a better way... func getPackageName(f string) string { diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go index 844691a94..8b261c124 100644 --- a/vendor/github.com/sirupsen/logrus/exported.go +++ b/vendor/github.com/sirupsen/logrus/exported.go @@ -55,7 +55,7 @@ func AddHook(hook Hook) { // WithError creates an entry from the standard logger and adds an error to it, // using the value defined in [ErrorKey] as key. func WithError(err error) *Entry { - return std.WithField(ErrorKey, err) + return std.WithError(err) } // WithContext creates an entry from the standard logger and adds a context to it. diff --git a/vendor/github.com/sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go index 9b0395adf..82c1f3da2 100644 --- a/vendor/github.com/sirupsen/logrus/text_formatter.go +++ b/vendor/github.com/sirupsen/logrus/text_formatter.go @@ -5,6 +5,7 @@ import ( "fmt" "maps" "os" + "reflect" "runtime" "slices" "strconv" @@ -329,10 +330,10 @@ func (f *TextFormatter) appendValue(b *bytes.Buffer, value any) { f.appendBytes(b, strconv.AppendBool(raw[:0], v)) return case error: - f.appendString(b, v.Error()) + f.appendError(b, v) return case fmt.Stringer: - f.appendString(b, v.String()) + f.appendStringer(b, v) return } @@ -417,6 +418,29 @@ func (f *TextFormatter) appendNumeric(b *bytes.Buffer, out []byte) { b.Write(out) } +func (f *TextFormatter) appendError(b *bytes.Buffer, v error) { + defer f.recoverValue(b, v, "Error") + + f.appendString(b, v.Error()) +} + +func (f *TextFormatter) appendStringer(b *bytes.Buffer, v fmt.Stringer) { + defer f.recoverValue(b, v, "String") + + f.appendString(b, v.String()) +} + +func (f *TextFormatter) recoverValue(b *bytes.Buffer, v any, method string) { + if r := recover(); r != nil { + rv := reflect.ValueOf(v) + if rv.Kind() == reflect.Pointer && rv.IsNil() { + f.appendString(b, "") + } else { + f.appendString(b, fmt.Sprintf("%%!v(PANIC=%s method: %v)", method, r)) + } + } +} + // needsQuoting returns true if the string contains any byte that // requires quoting. It returns false when every byte is "safe" according // to isSafeByte. diff --git a/vendor/modules.txt b/vendor/modules.txt index 3e0abc637..d222bd7fd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -158,7 +158,7 @@ github.com/prometheus/procfs/internal/util # github.com/russross/blackfriday/v2 v2.1.0 ## explicit github.com/russross/blackfriday/v2 -# github.com/sirupsen/logrus v1.10.0 +# github.com/sirupsen/logrus v1.10.1 ## explicit; go 1.23 github.com/sirupsen/logrus # github.com/spf13/pflag v1.0.10