Skip to content

Commit 703cea2

Browse files
committed
Model panicking log functions better
1 parent e6e8e3d commit 703cea2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • go/ql/lib/semmle/go/frameworks/stdlib

go/ql/lib/semmle/go/frameworks/stdlib/Log.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ module Log {
4747
override predicate mayReturnNormally() { none() }
4848
}
4949

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+
5063
// These models are not implemented using Models-as-Data because they represent reverse flow.
5164
private class FunctionModels extends TaintTracking::FunctionModel {
5265
FunctionInput inp;

0 commit comments

Comments
 (0)