mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
Python: model more loggers
This commit is contained in:
@@ -254,10 +254,14 @@ module Stdlib {
|
||||
* See https://docs.python.org/3.9/library/logging.html#logging.Logger.
|
||||
*/
|
||||
module Logger {
|
||||
private import semmle.python.dataflow.new.internal.DataFlowDispatch as DD
|
||||
|
||||
/** Gets a reference to the `logging.Logger` class or any subclass. */
|
||||
API::Node subclassRef() {
|
||||
result = API::moduleImport("logging").getMember("Logger").getASubclass*()
|
||||
or
|
||||
result = API::moduleImport("logging").getMember("getLoggerClass").getReturn().getASubclass*()
|
||||
or
|
||||
result = ModelOutput::getATypeNode("logging.Logger~Subclass").getASubclass*()
|
||||
}
|
||||
|
||||
@@ -277,6 +281,13 @@ module Stdlib {
|
||||
ClassInstantiation() {
|
||||
this = subclassRef().getACall()
|
||||
or
|
||||
this =
|
||||
DD::selfTracker(subclassRef()
|
||||
.getAValueReachableFromSource()
|
||||
.asExpr()
|
||||
.(ClassExpr)
|
||||
.getInnerScope())
|
||||
or
|
||||
this = API::moduleImport("logging").getMember("root").asSource()
|
||||
or
|
||||
this = API::moduleImport("logging").getMember("getLogger").getACall()
|
||||
|
||||
Reference in New Issue
Block a user