Skip to content

Commit e724f92

Browse files
committed
JS: Also summarize loads
1 parent ffc69cb commit e724f92

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

javascript/ql/src/semmle/javascript/dataflow/TypeTracking.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,15 @@ module StepSummary {
110110
or
111111
// Summarize calls with flow directly from a parameter to a return.
112112
exists(DataFlow::ParameterNode param, DataFlow::FunctionNode fun |
113-
param.flowsTo(fun.getAReturn()) and
114-
summary = LevelStep() and
113+
(
114+
param.flowsTo(fun.getAReturn()) and
115+
summary = LevelStep()
116+
or
117+
exists(string prop |
118+
param.getAPropertyRead(prop).flowsTo(fun.getAReturn()) and
119+
summary = LoadStep(prop)
120+
)
121+
) and
115122
if param = fun.getAParameter() then (
116123
// Step from argument to call site.
117124
argumentPassing(succ, pred, fun.getFunction(), param)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ test_Connection
3535
| tst.js:104:10:106:6 | (functi ... \\n })() |
3636
| tst.js:108:1:108:23 | shared( ... tion()) |
3737
| tst.js:108:8:108:22 | getConnection() |
38+
| tst.js:112:10:112:14 | obj.x |
39+
| tst.js:114:1:114:28 | getX({ ... on() }) |
40+
| tst.js:114:11:114:25 | getConnection() |
3841
| tst_conflict.js:6:38:6:77 | api.cha ... ction() |
3942
test_DataCallback
4043
| client.js:3:28:3:34 | x => {} |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ connection
1919
| type tracker with call steps | tst.js:93:5:93:18 | innerCapture() |
2020
| type tracker with call steps | tst.js:103:17:103:17 | x |
2121
| type tracker with call steps | tst.js:104:10:106:6 | (functi ... \\n })() |
22+
| type tracker with call steps | tst.js:112:10:112:14 | obj.x |
2223
| type tracker with call steps with property connection | tst.js:7:14:7:13 | this |
24+
| type tracker with call steps with property x | tst.js:111:15:111:17 | obj |
2325
| type tracker without call steps | client.js:1:10:1:27 | exportedConnection |
2426
| type tracker without call steps | tst.js:16:10:16:49 | api.cha ... ction() |
2527
| type tracker without call steps | tst.js:19:7:19:21 | getConnection() |
@@ -36,11 +38,14 @@ connection
3638
| type tracker without call steps | tst.js:100:12:100:26 | getConnection() |
3739
| type tracker without call steps | tst.js:108:1:108:23 | shared( ... tion()) |
3840
| type tracker without call steps | tst.js:108:8:108:22 | getConnection() |
41+
| type tracker without call steps | tst.js:114:1:114:28 | getX({ ... on() }) |
42+
| type tracker without call steps | tst.js:114:11:114:25 | getConnection() |
3943
| type tracker without call steps | tst_conflict.js:6:38:6:77 | api.cha ... ction() |
4044
| type tracker without call steps with property MyApplication.namespace.connection | file://:0:0:0:0 | global access path |
4145
| type tracker without call steps with property conflict | tst.js:63:3:63:25 | MyAppli ... mespace |
4246
| type tracker without call steps with property conflict | tst_conflict.js:6:3:6:25 | MyAppli ... mespace |
4347
| type tracker without call steps with property connection | tst.js:62:3:62:25 | MyAppli ... mespace |
48+
| type tracker without call steps with property x | tst.js:114:6:114:27 | { x: ge ... ion() } |
4449
dataCallback
4550
| client.js:3:28:3:34 | x => {} |
4651
| tst.js:10:11:10:12 | cb |

javascript/ql/test/library-tests/TypeTracking/tst.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ function shared(x) {
107107
}
108108
shared(getConnection());
109109
shared(somethingElse());
110+
111+
function getX(obj) {
112+
return obj.x;
113+
}
114+
getX({ x: getConnection() });
115+
getX({ x: somethingElse() });

0 commit comments

Comments
 (0)