Skip to content

Commit 62c895d

Browse files
author
Max Schaefer
committed
JavaScript: Introduce Type(Back)Tracker::continue predicate.
1 parent c097031 commit 62c895d

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ class TypeTracker extends TTypeTracker {
168168
boolean hasCall() { result = hasCall }
169169

170170
/**
171-
* Gets the property this type has been tracked into, or the empty string if
172-
* it has not been tracked into a property.
171+
* Gets a type tracker that starts where this one has left off to allow continued
172+
* tracking.
173+
*
174+
* This predicate is only defined if the type has not been tracked into a property.
173175
*/
174-
string getProp() { result = prop }
176+
TypeTracker continue() { prop = "" and result = this }
175177
}
176178

177179
module TypeTracker {
@@ -257,10 +259,12 @@ class TypeBackTracker extends TTypeBackTracker {
257259
boolean hasReturn() { result = hasReturn }
258260

259261
/**
260-
* Gets the property this type has been tracked into, or the empty string if
261-
* it has not been tracked into a property.
262+
* Gets a type tracker that starts where this one has left off to allow continued
263+
* tracking.
264+
*
265+
* This predicate is only defined if the type has not been tracked into a property.
262266
*/
263-
string getProp() { result = prop }
267+
TypeBackTracker continue() { prop = "" and result = this }
264268
}
265269

266270
module TypeBackTracker {

javascript/ql/src/semmle/javascript/frameworks/SocketIO.qll

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ module SocketIO {
5151
// exclude getter versions
5252
exists(mcn.getAnArgument()) and
5353
result = mcn and
54-
t2.getProp() = "" and
55-
t = t2
54+
t = t2.continue()
5655
)
5756
)
5857
}
@@ -111,8 +110,7 @@ module SocketIO {
111110
or
112111
// invocation of a chainable method
113112
result = pred.getAMethodCall(namespaceChainableMethod()) and
114-
t2.getProp() = "" and
115-
t = t2
113+
t = t2.continue()
116114
or
117115
// invocation of chainable getter method
118116
exists(string m |
@@ -121,8 +119,7 @@ module SocketIO {
121119
m = "volatile"
122120
|
123121
result = pred.getAPropertyRead(m) and
124-
t2.getProp() = "" and
125-
t = t2
122+
t = t2.continue()
126123
)
127124
)
128125
}
@@ -174,8 +171,7 @@ module SocketIO {
174171
m = EventEmitter::chainableMethod()
175172
|
176173
result = pred.getAMethodCall(m) and
177-
t2.getProp() = "" and
178-
t = t2
174+
t = t2.continue()
179175
)
180176
or
181177
// invocation of a chainable getter method
@@ -186,8 +182,7 @@ module SocketIO {
186182
m = "volatile"
187183
|
188184
result = pred.getAPropertyRead(m) and
189-
t2.getProp() = "" and
190-
t = t2
185+
t = t2.continue()
191186
)
192187
)
193188
}

0 commit comments

Comments
 (0)