зеркало из https://github.com/github/codeql.git
add indirect calls to logging methods as logging methods
This commit is contained in:
Родитель
351cb46bb9
Коммит
b12e255fd8
|
@ -62,7 +62,40 @@ private module Console {
|
|||
then result = getArgument([1 .. getNumArgument()])
|
||||
else result = getAnArgument()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the console logging method, e.g. "log", "error", "assert", etc.
|
||||
*/
|
||||
string getName() {
|
||||
result = name
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to a function that forwards all arguments to some console logging mechanism.
|
||||
* The called function contain a single statement similar to: `console.log.apply(this, arguments)`.
|
||||
*/
|
||||
class IndirectConsoleLoggerCall extends LoggerCall {
|
||||
ConsoleLoggerCall consoleCall;
|
||||
DataFlow::MethodCallNode applyCall;
|
||||
|
||||
IndirectConsoleLoggerCall() {
|
||||
forex(Function f | f = this.getACallee() |
|
||||
f.getNumBodyStmt() = 1 and
|
||||
consoleCall.getContainer() = f and
|
||||
applyCall.getContainer() = f and
|
||||
applyCall.getMethodName() = "apply" and
|
||||
applyCall.getReceiver() = consoleCall.getCalleeNode() and
|
||||
applyCall.getArgument(1).asExpr().(VarAccess).getName() = "arguments"
|
||||
)
|
||||
}
|
||||
|
||||
override DataFlow::Node getAMessageComponent() {
|
||||
if consoleCall.getName() = "assert"
|
||||
then result = getArgument([1 .. getNumArgument()])
|
||||
else result = getAnArgument()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче