Skip to content

Commit 4ac21e9

Browse files
committed
make the .filter step more precise
1 parent ab53f3b commit 4ac21e9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

javascript/ql/src/semmle/javascript/Arrays.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ module ArrayTaintTracking {
3636
succ = call
3737
)
3838
or
39-
// `array.filter` keeps the taint
39+
// `array.filter(x => x)` keeps the taint
4040
call.(DataFlow::MethodCallNode).getMethodName() = "filter" and
4141
pred = call.getReceiver() and
42-
succ = call
42+
succ = call and
43+
exists(DataFlow::FunctionNode callback | callback = call.getArgument(0).getAFunctionValue() |
44+
callback.getParameter(0).getALocalUse() = callback.getAReturn()
45+
)
4346
or
4447
// `array.reduce` with tainted value in callback
4548
call.(DataFlow::MethodCallNode).getMethodName() = "reduce" and

0 commit comments

Comments
 (0)