Skip to content

Commit 6fa2d27

Browse files
authored
Don't treat logrus' WithContext method as a logging function
This isn't output by the default formatters (though a custom formatter could potentially output things stored in it)
1 parent a98ae89 commit 6fa2d27

File tree

2 files changed

+2
-2
lines changed
  • go/ql

2 files changed

+2
-2
lines changed

go/ql/lib/semmle/go/frameworks/Logrus.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Logrus {
1616

1717
bindingset[result]
1818
private string getAnEntryUpdatingMethodName() {
19-
result.regexpMatch("With(Context|Error|Fields?|Time)")
19+
result.regexpMatch("With(Error|Fields?|Time)")
2020
}
2121

2222
private class LogFunction extends Function {

go/ql/test/library-tests/semmle/go/concepts/LoggerCall/logrus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func logrusCalls() {
1818
var fields logrus.Fields = nil
1919
var fn logrus.LogFunction = nil
2020
var ctx context.Context
21-
tmp := logrus.WithContext(ctx) // $ logger=ctx
21+
tmp := logrus.WithContext(ctx) // ctx isn't output, so no match here
2222
tmp.Debugf(fmt, text) // $ logger=fmt logger=text
2323
tmp = logrus.WithError(err) // $ logger=err
2424
tmp.Warn(text) // $ logger=text

0 commit comments

Comments
 (0)