Skip to content

Commit 938938c

Browse files
committed
JS: Use pragma[noopt] to force join order in trackUsenode
1 parent 9f001f8 commit 938938c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,11 +1285,12 @@ module API {
12851285
* - `prop`: if non-empty, the flow is only guaranteed to preserve the value of this property,
12861286
* and not necessarily the entire object.
12871287
*/
1288+
pragma[noopt]
12881289
private RawSourceNode trackUseNode(
12891290
RawSourceNode nd, boolean promisified, int boundArgs, string prop, DataFlow::TypeTracker t
12901291
) {
1291-
t.start() and
12921292
use(_, nd) and
1293+
t.start() and
12931294
result = nd and
12941295
promisified = false and
12951296
boundArgs = 0 and
@@ -1299,8 +1300,7 @@ module API {
12991300
prev = trackUseNode(nd, prevPromisified, prevBoundArgs, prevProp, t)
13001301
|
13011302
promisificationBigStep(prev, result) and
1302-
prevPromisified = false and
1303-
prevProp = "" and
1303+
validPromisificationState(prevPromisified, prevProp) and
13041304
promisified = prevPromisified and
13051305
boundArgs = prevBoundArgs and
13061306
prop = prevProp
@@ -1313,8 +1313,7 @@ module API {
13131313
)
13141314
or
13151315
loadStoreBigStep(prev, result, prop) and
1316-
prevPromisified = false and
1317-
prevBoundArgs = 0 and
1316+
validLoadStoreBigState(prevPromisified, prevBoundArgs) and
13181317
promisified = prevPromisified and
13191318
boundArgs = prevBoundArgs and
13201319
prevProp = [prop, ""]
@@ -1323,12 +1322,23 @@ module API {
13231322
or
13241323
exists(DataFlow::SourceNode mid |
13251324
mid = trackUseNode(nd, promisified, boundArgs, prop, t) and
1326-
AdditionalUseStep::step(pragma[only_bind_out](mid), result)
1325+
AdditionalUseStep::step(mid, result)
13271326
)
13281327
or
13291328
t = useStep(nd, promisified, boundArgs, prop, result)
13301329
}
13311330

1331+
pragma[nomagic]
1332+
private predicate validPromisificationState(boolean promisified, string prop) {
1333+
promisified = false and
1334+
prop = ""
1335+
}
1336+
1337+
pragma[nomagic]
1338+
private predicate validLoadStoreBigState(boolean promisified, int boundArgs) {
1339+
promisified = false and boundArgs = 0
1340+
}
1341+
13321342
pragma[nomagic]
13331343
private predicate promisificationBigStep(DataFlow::SourceNode node1, DataFlow::SourceNode node2) {
13341344
exists(Promisify::PromisifyCall promisify |

0 commit comments

Comments
 (0)