Skip to content

Commit 06f1eec

Browse files
committed
Revert "JS: Convert boolean to a newtype"
This reverts commit bac3951.
1 parent c4dc2f5 commit 06f1eec

1 file changed

Lines changed: 9 additions & 31 deletions

File tree

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

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ module API {
10431043
// property reads
10441044
exists(DataFlow::SourceNode src, DataFlow::SourceNode pred, string propDesc |
10451045
use(base, src) and
1046-
pred = trackUseNode(src, Promisification::notPromisified(), 0, propDesc) and
1046+
pred = trackUseNode(src, false, 0, propDesc) and
10471047
propertyRead(pred, propDesc, lbl, ref) and
10481048
// `module.exports` is special: it is a use of a def-node, not a use-node,
10491049
// so we want to exclude it here
@@ -1253,26 +1253,6 @@ module API {
12531253

12541254
private import semmle.javascript.dataflow.TypeTracking
12551255

1256-
private module Promisification {
1257-
private newtype TState =
1258-
/** Default statue; the tracked value has not been through any steps related to promisification. */
1259-
TNotPromisified() or
1260-
/** The tracked value is a function that has been through promisification. */
1261-
TPromisifiedFunction()
1262-
1263-
class State extends TState {
1264-
string toString() {
1265-
this = TNotPromisified() and result = "not-promisified"
1266-
or
1267-
this = TPromisifiedFunction() and result = "promisified-function"
1268-
}
1269-
}
1270-
1271-
State notPromisified() { result = TNotPromisified() }
1272-
1273-
State promisifiedFunction() { result = TPromisifiedFunction() }
1274-
}
1275-
12761256
/**
12771257
* Gets a data-flow node to which `nd`, which is a use of an API-graph node, flows.
12781258
*
@@ -1287,20 +1267,19 @@ module API {
12871267
* and not necessarily the entire object.
12881268
*/
12891269
private DataFlow::SourceNode trackUseNode(
1290-
DataFlow::SourceNode nd, Promisification::State promisified, int boundArgs, string prop,
1270+
DataFlow::SourceNode nd, boolean promisified, int boundArgs, string prop,
12911271
DataFlow::TypeTracker t
12921272
) {
12931273
t.start() and
12941274
use(_, nd) and
12951275
result = nd and
1296-
promisified = Promisification::notPromisified() and
1276+
promisified = false and
12971277
boundArgs = 0 and
12981278
prop = ""
12991279
or
13001280
exists(Promisify::PromisifyCall promisify |
1301-
trackUseNode(nd, Promisification::notPromisified(), boundArgs, prop, t.continue())
1302-
.flowsTo(promisify.getArgument(0)) and
1303-
promisified = Promisification::promisifiedFunction() and
1281+
trackUseNode(nd, false, boundArgs, prop, t.continue()).flowsTo(promisify.getArgument(0)) and
1282+
promisified = true and
13041283
prop = "" and
13051284
result = promisify
13061285
)
@@ -1319,7 +1298,7 @@ module API {
13191298
or
13201299
exists(DataFlow::Node pred, string preprop |
13211300
trackUseNode(nd, promisified, boundArgs, preprop, t.continue()).flowsTo(pred) and
1322-
promisified = Promisification::notPromisified() and
1301+
promisified = false and
13231302
boundArgs = 0 and
13241303
SharedTypeTrackingStep::loadStoreStep(pred, result, prop)
13251304
|
@@ -1340,8 +1319,7 @@ module API {
13401319
*/
13411320
pragma[noopt]
13421321
private DataFlow::TypeTracker useStep(
1343-
DataFlow::Node nd, Promisification::State promisified, int boundArgs, string prop,
1344-
DataFlow::Node res
1322+
DataFlow::Node nd, boolean promisified, int boundArgs, string prop, DataFlow::Node res
13451323
) {
13461324
exists(DataFlow::TypeTracker t, StepSummary summary, DataFlow::SourceNode prev |
13471325
prev = trackUseNode(nd, promisified, boundArgs, prop, t) and
@@ -1353,7 +1331,7 @@ module API {
13531331
}
13541332

13551333
private DataFlow::SourceNode trackUseNode(
1356-
DataFlow::SourceNode nd, Promisification::State promisified, int boundArgs, string prop
1334+
DataFlow::SourceNode nd, boolean promisified, int boundArgs, string prop
13571335
) {
13581336
result = trackUseNode(nd, promisified, boundArgs, prop, DataFlow::TypeTracker::end())
13591337
}
@@ -1363,7 +1341,7 @@ module API {
13631341
*/
13641342
cached
13651343
DataFlow::SourceNode trackUseNode(DataFlow::SourceNode nd) {
1366-
result = trackUseNode(nd, Promisification::notPromisified(), 0, "")
1344+
result = trackUseNode(nd, false, 0, "")
13671345
}
13681346

13691347
private DataFlow::SourceNode trackDefNode(DataFlow::Node nd, DataFlow::TypeBackTracker t) {

0 commit comments

Comments
 (0)