File tree Expand file tree Collapse file tree
javascript/ql/src/semmle/javascript/frameworks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -586,22 +586,27 @@ module NodeJSLib {
586586 }
587587 }
588588
589+ /**
590+ * Gets a possibly promisified (using `util.promisify`) version of the input `func`.
591+ */
592+ DataFlow:: SourceNode maybePromisified ( DataFlow:: SourceNode func ) {
593+ result = func
594+ or
595+ exists ( DataFlow:: CallNode promisify |
596+ promisify = DataFlow:: moduleMember ( "util" , "promisify" ) .getACall ( )
597+ |
598+ result = promisify and promisify .getArgument ( 0 ) .getALocalSource ( ) = func
599+ )
600+ }
601+
589602 /**
590603 * A call to a method from module `child_process`.
591604 */
592605 private class ChildProcessMethodCall extends SystemCommandExecution , DataFlow:: CallNode {
593606 string methodName ;
594607
595608 ChildProcessMethodCall ( ) {
596- this = DataFlow:: moduleMember ( "child_process" , methodName ) .getACall ( )
597- or
598- exists ( DataFlow:: CallNode promisify |
599- promisify = DataFlow:: moduleMember ( "util" , "promisify" ) .getACall ( )
600- |
601- this = promisify .getACall ( ) and
602- promisify .getArgument ( 0 ) .getALocalSource ( ) =
603- DataFlow:: moduleMember ( "child_process" , methodName )
604- )
609+ this = maybePromisified ( DataFlow:: moduleMember ( "child_process" , methodName ) ) .getACall ( )
605610 }
606611
607612 private DataFlow:: Node getACommandArgument ( boolean shell ) {
You can’t perform that action at this time.
0 commit comments