mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
refactor into maybePromisified predicate
This commit is contained in:
@@ -586,6 +586,19 @@ module NodeJSLib {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a possibly promisified (using `util.promisify`) version of the input `func`.
|
||||
*/
|
||||
DataFlow::SourceNode maybePromisified(DataFlow::SourceNode func) {
|
||||
result = func
|
||||
or
|
||||
exists(DataFlow::CallNode promisify |
|
||||
promisify = DataFlow::moduleMember("util", "promisify").getACall()
|
||||
|
|
||||
result = promisify and promisify.getArgument(0).getALocalSource() = func
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to a method from module `child_process`.
|
||||
*/
|
||||
@@ -593,15 +606,7 @@ module NodeJSLib {
|
||||
string methodName;
|
||||
|
||||
ChildProcessMethodCall() {
|
||||
this = DataFlow::moduleMember("child_process", methodName).getACall()
|
||||
or
|
||||
exists(DataFlow::CallNode promisify |
|
||||
promisify = DataFlow::moduleMember("util", "promisify").getACall()
|
||||
|
|
||||
this = promisify.getACall() and
|
||||
promisify.getArgument(0).getALocalSource() =
|
||||
DataFlow::moduleMember("child_process", methodName)
|
||||
)
|
||||
this = maybePromisified(DataFlow::moduleMember("child_process", methodName)).getACall()
|
||||
}
|
||||
|
||||
private DataFlow::Node getACommandArgument(boolean shell) {
|
||||
|
||||
Reference in New Issue
Block a user