Skip to content

Commit 7c94dd9

Browse files
committed
JS: Add type-tracking steps through callback args
1 parent 1f6df4e commit 7c94dd9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/StepSummary.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ private module Cached {
156156
succ = fun.getAnInvocation()
157157
)
158158
)
159+
or
160+
// Add 'return' steps from callback arguments to callback parameters
161+
exists(DataFlow::ParameterNode cbParam, DataFlow::FunctionNode cbFun, int i |
162+
callStep(cbFun, cbParam) and
163+
pred = cbParam.getAnInvocation().getArgument(i) and
164+
succ = cbFun.getParameter(i) and
165+
summary = ReturnStep()
166+
)
159167
}
160168
}
161169

javascript/ql/test/library-tests/TypeTracking/PredicateStyle.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ connection
4141
| type tracker without call steps | tst.js:114:1:114:28 | getX({ ... on() }) |
4242
| type tracker without call steps | tst.js:114:11:114:25 | getConnection() |
4343
| type tracker without call steps | tst.js:118:12:118:26 | getConnection() |
44+
| type tracker without call steps | tst.js:120:21:120:24 | conn |
4445
| type tracker without call steps | tst_conflict.js:6:38:6:77 | api.cha ... ction() |
4546
| type tracker without call steps with property MyApplication.namespace.connection | file://:0:0:0:0 | global access path |
4647
| type tracker without call steps with property conflict | tst.js:63:3:63:25 | MyAppli ... mespace |

0 commit comments

Comments
 (0)