simplify the logging sink - using the new API-graph logging models

This commit is contained in:
Erik Krogh Kristensen
2020-11-30 16:30:09 +01:00
parent 6f29a877fa
commit dea2eb5443

View File

@@ -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() }
}
/**