Skip to content

Commit 571be8b

Browse files
committed
Python: model more loggers
1 parent eb32cbe commit 571be8b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,14 @@ module Stdlib {
254254
* See https://docs.python.org/3.9/library/logging.html#logging.Logger.
255255
*/
256256
module Logger {
257+
private import semmle.python.dataflow.new.internal.DataFlowDispatch as DD
258+
257259
/** Gets a reference to the `logging.Logger` class or any subclass. */
258260
API::Node subclassRef() {
259261
result = API::moduleImport("logging").getMember("Logger").getASubclass*()
260262
or
263+
result = API::moduleImport("logging").getMember("getLoggerClass").getReturn().getASubclass*()
264+
or
261265
result = ModelOutput::getATypeNode("logging.Logger~Subclass").getASubclass*()
262266
}
263267

@@ -277,6 +281,13 @@ module Stdlib {
277281
ClassInstantiation() {
278282
this = subclassRef().getACall()
279283
or
284+
this =
285+
DD::selfTracker(subclassRef()
286+
.getAValueReachableFromSource()
287+
.asExpr()
288+
.(ClassExpr)
289+
.getInnerScope())
290+
or
280291
this = API::moduleImport("logging").getMember("root").asSource()
281292
or
282293
this = API::moduleImport("logging").getMember("getLogger").getACall()

0 commit comments

Comments
 (0)