Skip to content

Commit ec2b089

Browse files
committed
JS: Add missing flow steps.
1 parent b283fc9 commit ec2b089

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,22 @@ module NodeJSLib {
10321032
bufferInstance(DataFlow::TypeTracker::end()).flowsTo(node)
10331033
}
10341034

1035+
private DataFlow::SourceNode pipeTransformCallback(PipeHookCall call, DataFlow::TypeTracker t) {
1036+
t.start() and
1037+
call.getMethodName() = "_transform" and
1038+
result = call.getArgument(2)
1039+
or
1040+
exists(DataFlow::TypeTracker t0 | result = pipeTransformCallback(call, t0).track(t0, t))
1041+
}
1042+
1043+
private DataFlow::SourceNode pipeTransformReceiver(PipeHookCall call, DataFlow::TypeTracker t) {
1044+
t.start() and
1045+
call.getMethodName() = "_transform" and
1046+
result = call.getReceiver().getALocalSource()
1047+
or
1048+
exists(DataFlow::TypeTracker t0 | result = pipeTransformReceiver(call, t0).track(t0, t))
1049+
}
1050+
10351051
overlay[local?]
10361052
private class StreamFlowStep extends AdditionalFlowInternal {
10371053
override predicate needsSynthesizedNode(AstNode node, string tag, DataFlowCallable container) {
@@ -1105,6 +1121,20 @@ module NodeJSLib {
11051121
contents = DataFlow::ContentSet::iteratorElement() and
11061122
succ = call.flow()
11071123
)
1124+
or
1125+
exists(PipeHookCall hook, DataFlow::CallNode callback |
1126+
callback = pipeTransformCallback(hook, DataFlow::TypeTracker::end()).getACall() and
1127+
pred = callback.getArgument(1) and
1128+
contents = DataFlow::ContentSet::iteratorElement() and
1129+
succ = hook.getReceiver()
1130+
)
1131+
or
1132+
exists(PipeHookCall hook, DataFlow::MethodCallNode push |
1133+
push = pipeTransformReceiver(hook, DataFlow::TypeTracker::end()).getAMethodCall("push") and
1134+
pred = push.getArgument(0) and
1135+
contents = DataFlow::ContentSet::iteratorElement() and
1136+
succ = hook.getReceiver()
1137+
)
11081138
}
11091139
}
11101140

0 commit comments

Comments
 (0)