mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
simplify the logging sink - using the new API-graph logging models
This commit is contained in:
@@ -40,45 +40,11 @@ module LogInjection {
|
||||
RemoteSource() { this instanceof RemoteFlowSource }
|
||||
}
|
||||
|
||||
/**
|
||||
* An source node representing a logging mechanism.
|
||||
*/
|
||||
class ConsoleSource extends DataFlow::SourceNode {
|
||||
ConsoleSource() {
|
||||
exists(DataFlow::SourceNode node |
|
||||
node = this and this = DataFlow::moduleImport("console")
|
||||
or
|
||||
this = DataFlow::globalVarRef("console")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to a logging mechanism. For example, the call could be in the following forms:
|
||||
* `console.log('hello')` or
|
||||
*
|
||||
* `let logger = console.log;`
|
||||
* `logger('hello')` or
|
||||
*
|
||||
* `let logger = {info: console.log};`
|
||||
* `logger.info('hello')`
|
||||
*/
|
||||
class LoggingCall extends DataFlow::CallNode {
|
||||
LoggingCall() {
|
||||
exists(DataFlow::SourceNode node, string propName |
|
||||
any(ConsoleSource console).getAPropertyRead() = node.getAPropertySource(propName) and
|
||||
this = node.getAPropertyRead(propName).getACall()
|
||||
)
|
||||
or
|
||||
this = any(LoggerCall call)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An argument to a logging mechanism.
|
||||
*/
|
||||
class LoggingSink extends Sink {
|
||||
LoggingSink() { this = any(LoggingCall console).getAnArgument() }
|
||||
LoggingSink() { this = any(LoggerCall console).getAMessageComponent() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user