Skip to content

Commit 5026454

Browse files
japrocesbena
authored andcommitted
make array taint-step better
1 parent aa36556 commit 5026454

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

javascript/ql/lib/semmle/javascript/Arrays.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ module ArrayTaintTracking {
3636
succ = call
3737
)
3838
or
39-
// `array.filter(x => x)` keeps the taint
39+
// `array.filter(x => x)` and `array.filter(x => !!x)` keeps the taint
4040
call.(DataFlow::MethodCallNode).getMethodName() = "filter" and
4141
pred = call.getReceiver() and
4242
succ = call and
43-
exists(DataFlow::FunctionNode callback | callback = call.getArgument(0).getAFunctionValue() |
44-
callback.getParameter(0).getALocalUse() = callback.getAReturn()
43+
exists(DataFlow::FunctionNode callback, DataFlow::Node param, DataFlow::Node ret |
44+
callback = call.getArgument(0).getAFunctionValue() and
45+
param = callback.getParameter(0).getALocalUse() and
46+
ret = callback.getAReturn()
47+
|
48+
param = ret
49+
or
50+
param = DataFlow::exprNode(ret.asExpr().(LogNotExpr).getOperand().(LogNotExpr).getOperand())
4551
)
4652
or
4753
// `array.reduce` with tainted value in callback

0 commit comments

Comments
 (0)