@@ -29,18 +29,37 @@ module Log {
2929 }
3030
3131 private class LogFormatter extends StringOps:: Formatting:: Range instanceof LogFunction {
32- LogFormatter ( ) { this .getName ( ) = [ "Fatalf" , "Panicf" , "Printf" ] }
32+ LogFormatter ( ) { this .getName ( ) = [ "Fatalf" , "Panicf" , "Printf" , "Panic" , "Panicf" , "Panicln" ] }
3333
3434 override int getFormatStringIndex ( ) { result = 0 }
3535 }
3636
3737 /** A fatal log function, which calls `os.Exit`. */
3838 private class FatalLogFunction extends Function {
39- FatalLogFunction ( ) { this .hasQualifiedName ( "log" , [ "Fatal" , "Fatalf" , "Fatalln" ] ) }
39+ FatalLogFunction ( ) {
40+ exists ( string fn | fn = [ "Fatal" , "Fatalf" , "Fatalln" ] |
41+ this .hasQualifiedName ( "log" , fn )
42+ or
43+ this .( Method ) .hasQualifiedName ( "log" , "Logger" , fn )
44+ )
45+ }
4046
4147 override predicate mayReturnNormally ( ) { none ( ) }
4248 }
4349
50+ /** A log function which must panic. */
51+ private class PanicLogFunction extends Function {
52+ PanicLogFunction ( ) {
53+ exists ( string fn | fn = [ "Panic" , "Panicf" , "Panicln" ] |
54+ this .hasQualifiedName ( "log" , fn )
55+ or
56+ this .( Method ) .hasQualifiedName ( "log" , "Logger" , fn )
57+ )
58+ }
59+
60+ override predicate mustPanic ( ) { any ( ) }
61+ }
62+
4463 // These models are not implemented using Models-as-Data because they represent reverse flow.
4564 private class FunctionModels extends TaintTracking:: FunctionModel {
4665 FunctionInput inp ;
@@ -63,30 +82,6 @@ module Log {
6382 FunctionOutput outp ;
6483
6584 MethodModels ( ) {
66- // signature: func (*Logger) Fatal(v ...interface{})
67- this .hasQualifiedName ( "log" , "Logger" , "Fatal" ) and
68- ( inp .isParameter ( _) and outp .isReceiver ( ) )
69- or
70- // signature: func (*Logger) Fatalf(format string, v ...interface{})
71- this .hasQualifiedName ( "log" , "Logger" , "Fatalf" ) and
72- ( inp .isParameter ( _) and outp .isReceiver ( ) )
73- or
74- // signature: func (*Logger) Fatalln(v ...interface{})
75- this .hasQualifiedName ( "log" , "Logger" , "Fatalln" ) and
76- ( inp .isParameter ( _) and outp .isReceiver ( ) )
77- or
78- // signature: func (*Logger) Panic(v ...interface{})
79- this .hasQualifiedName ( "log" , "Logger" , "Panic" ) and
80- ( inp .isParameter ( _) and outp .isReceiver ( ) )
81- or
82- // signature: func (*Logger) Panicf(format string, v ...interface{})
83- this .hasQualifiedName ( "log" , "Logger" , "Panicf" ) and
84- ( inp .isParameter ( _) and outp .isReceiver ( ) )
85- or
86- // signature: func (*Logger) Panicln(v ...interface{})
87- this .hasQualifiedName ( "log" , "Logger" , "Panicln" ) and
88- ( inp .isParameter ( _) and outp .isReceiver ( ) )
89- or
9085 // signature: func (*Logger) Print(v ...interface{})
9186 this .hasQualifiedName ( "log" , "Logger" , "Print" ) and
9287 ( inp .isParameter ( _) and outp .isReceiver ( ) )
0 commit comments