Skip to content

Commit 791313f

Browse files
committed
Add tests for logrus.FieldLogger
1 parent cc62db7 commit 791313f

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

go/ql/test/query-tests/Security/CWE-117/LogInjection.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package main
77
//go:generate depstubber -vendor github.com/davecgh/go-spew/spew "" Dump,Errorf,Print,Printf,Println,Fdump,Fprint,Fprintf,Fprintln
88
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
99
//go:generate depstubber -vendor github.com/golang/glog Level,Verbose Info,InfoDepth,Infof,Infoln,Error,ErrorDepth,Errorf,Errorln,Fatal,FatalDepth,Fatalf,Fatalln,Exit,ExitDepth,Exitf,Exitln,V
10-
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Entry,Logger,Level Debug,Debugf,Debugln,Error,Errorf,Errorln,Fatal,Fatalf,Fatalln,Info,Infof,Infoln,Panic,Panicf,Panicln,Print,Printf,Println,Trace,Tracef,Traceln,Warn,Warnf,Warnln,Warning,Warningf,Warningln,WithFields,WithField
10+
//go:generate depstubber -vendor github.com/sirupsen/logrus FieldLogger,Fields,Entry,Logger,Level Debug,Debugf,Debugln,Error,Errorf,Errorln,Fatal,Fatalf,Fatalln,Info,Infof,Infoln,Panic,Panicf,Panicln,Print,Printf,Println,Trace,Tracef,Traceln,Warn,Warnf,Warnln,Warning,Warningf,Warningln,WithFields,WithField
1111
//go:generate depstubber -vendor go.uber.org/zap Logger,SugaredLogger NewProduction
1212

1313
import (
@@ -293,6 +293,40 @@ func handler(req *http.Request, ctx *goproxy.ProxyCtx) {
293293
logger.Warningf(username, "") // $ hasTaintFlow="username"
294294
logger.Warningf("", username) // $ hasTaintFlow="username"
295295
logger.Warningln(username) // $ hasTaintFlow="username"
296+
297+
var fieldlogger logrus.FieldLogger = entry
298+
fieldlogger.Debug(username) // $ hasTaintFlow="username"
299+
fieldlogger.Debugf(username, "") // $ hasTaintFlow="username"
300+
fieldlogger.Debugf("", username) // $ hasTaintFlow="username"
301+
fieldlogger.Debugln(username) // $ hasTaintFlow="username"
302+
fieldlogger.Error(username) // $ hasTaintFlow="username"
303+
fieldlogger.Errorf(username, "") // $ hasTaintFlow="username"
304+
fieldlogger.Errorf("", username) // $ hasTaintFlow="username"
305+
fieldlogger.Errorln(username) // $ hasTaintFlow="username"
306+
fieldlogger.Fatal(username) // $ hasTaintFlow="username"
307+
fieldlogger.Fatalf(username, "") // $ hasTaintFlow="username"
308+
fieldlogger.Fatalf("", username) // $ hasTaintFlow="username"
309+
fieldlogger.Fatalln(username) // $ hasTaintFlow="username"
310+
fieldlogger.Info(username) // $ hasTaintFlow="username"
311+
fieldlogger.Infof(username, "") // $ hasTaintFlow="username"
312+
fieldlogger.Infof("", username) // $ hasTaintFlow="username"
313+
fieldlogger.Infoln(username) // $ hasTaintFlow="username"
314+
fieldlogger.Panic(username) // $ hasTaintFlow="username"
315+
fieldlogger.Panicf(username, "") // $ hasTaintFlow="username"
316+
fieldlogger.Panicf("", username) // $ hasTaintFlow="username"
317+
fieldlogger.Panicln(username) // $ hasTaintFlow="username"
318+
fieldlogger.Print(username) // $ hasTaintFlow="username"
319+
fieldlogger.Printf(username, "") // $ hasTaintFlow="username"
320+
fieldlogger.Printf("", username) // $ hasTaintFlow="username"
321+
fieldlogger.Println(username) // $ hasTaintFlow="username"
322+
fieldlogger.Warn(username) // $ hasTaintFlow="username"
323+
fieldlogger.Warnf(username, "") // $ hasTaintFlow="username"
324+
fieldlogger.Warnf("", username) // $ hasTaintFlow="username"
325+
fieldlogger.Warnln(username) // $ hasTaintFlow="username"
326+
fieldlogger.Warning(username) // $ hasTaintFlow="username"
327+
fieldlogger.Warningf(username, "") // $ hasTaintFlow="username"
328+
fieldlogger.Warningf("", username) // $ hasTaintFlow="username"
329+
fieldlogger.Warningln(username) // $ hasTaintFlow="username"
296330
}
297331
// davecgh/go-spew/spew
298332
{

go/ql/test/query-tests/Security/CWE-117/vendor/github.com/sirupsen/logrus/stub.go

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)