Add tests for logrus.FieldLogger

This commit is contained in:
Owen Mansel-Chan
2024-09-12 11:29:01 +01:00
parent cc62db796c
commit 791313fbdf
2 changed files with 66 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ package main
//go:generate depstubber -vendor github.com/davecgh/go-spew/spew "" Dump,Errorf,Print,Printf,Println,Fdump,Fprint,Fprintf,Fprintln
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
//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
//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
//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
//go:generate depstubber -vendor go.uber.org/zap Logger,SugaredLogger NewProduction
import (
@@ -293,6 +293,40 @@ func handler(req *http.Request, ctx *goproxy.ProxyCtx) {
logger.Warningf(username, "") // $ hasTaintFlow="username"
logger.Warningf("", username) // $ hasTaintFlow="username"
logger.Warningln(username) // $ hasTaintFlow="username"
var fieldlogger logrus.FieldLogger = entry
fieldlogger.Debug(username) // $ hasTaintFlow="username"
fieldlogger.Debugf(username, "") // $ hasTaintFlow="username"
fieldlogger.Debugf("", username) // $ hasTaintFlow="username"
fieldlogger.Debugln(username) // $ hasTaintFlow="username"
fieldlogger.Error(username) // $ hasTaintFlow="username"
fieldlogger.Errorf(username, "") // $ hasTaintFlow="username"
fieldlogger.Errorf("", username) // $ hasTaintFlow="username"
fieldlogger.Errorln(username) // $ hasTaintFlow="username"
fieldlogger.Fatal(username) // $ hasTaintFlow="username"
fieldlogger.Fatalf(username, "") // $ hasTaintFlow="username"
fieldlogger.Fatalf("", username) // $ hasTaintFlow="username"
fieldlogger.Fatalln(username) // $ hasTaintFlow="username"
fieldlogger.Info(username) // $ hasTaintFlow="username"
fieldlogger.Infof(username, "") // $ hasTaintFlow="username"
fieldlogger.Infof("", username) // $ hasTaintFlow="username"
fieldlogger.Infoln(username) // $ hasTaintFlow="username"
fieldlogger.Panic(username) // $ hasTaintFlow="username"
fieldlogger.Panicf(username, "") // $ hasTaintFlow="username"
fieldlogger.Panicf("", username) // $ hasTaintFlow="username"
fieldlogger.Panicln(username) // $ hasTaintFlow="username"
fieldlogger.Print(username) // $ hasTaintFlow="username"
fieldlogger.Printf(username, "") // $ hasTaintFlow="username"
fieldlogger.Printf("", username) // $ hasTaintFlow="username"
fieldlogger.Println(username) // $ hasTaintFlow="username"
fieldlogger.Warn(username) // $ hasTaintFlow="username"
fieldlogger.Warnf(username, "") // $ hasTaintFlow="username"
fieldlogger.Warnf("", username) // $ hasTaintFlow="username"
fieldlogger.Warnln(username) // $ hasTaintFlow="username"
fieldlogger.Warning(username) // $ hasTaintFlow="username"
fieldlogger.Warningf(username, "") // $ hasTaintFlow="username"
fieldlogger.Warningf("", username) // $ hasTaintFlow="username"
fieldlogger.Warningln(username) // $ hasTaintFlow="username"
}
// davecgh/go-spew/spew
{

View File

@@ -2,7 +2,7 @@
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Entry,Logger,Level; functions: 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)
// Source: github.com/sirupsen/logrus (exports: FieldLogger,Fields,Entry,Logger,Level; functions: 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)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
@@ -148,6 +148,36 @@ func Fatalf(_ string, _ ...interface{}) {}
func Fatalln(_ ...interface{}) {}
type FieldLogger interface {
Debug(_ ...interface{})
Debugf(_ string, _ ...interface{})
Debugln(_ ...interface{})
Error(_ ...interface{})
Errorf(_ string, _ ...interface{})
Errorln(_ ...interface{})
Fatal(_ ...interface{})
Fatalf(_ string, _ ...interface{})
Fatalln(_ ...interface{})
Info(_ ...interface{})
Infof(_ string, _ ...interface{})
Infoln(_ ...interface{})
Panic(_ ...interface{})
Panicf(_ string, _ ...interface{})
Panicln(_ ...interface{})
Print(_ ...interface{})
Printf(_ string, _ ...interface{})
Println(_ ...interface{})
Warn(_ ...interface{})
Warnf(_ string, _ ...interface{})
Warning(_ ...interface{})
Warningf(_ string, _ ...interface{})
Warningln(_ ...interface{})
Warnln(_ ...interface{})
WithError(_ error) *Entry
WithField(_ string, _ interface{}) *Entry
WithFields(_ Fields) *Entry
}
type Fields map[string]interface{}
type Formatter interface {