Skip to content

Commit eb80705

Browse files
committed
add a taint-step for require("bluebird").mapSeries()
1 parent b97c09a commit eb80705

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

javascript/ql/src/semmle/javascript/Promises.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,18 @@ predicate promiseTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
440440
pred.getEnclosingExpr() = await.getOperand() and
441441
succ.getEnclosingExpr() = await
442442
)
443+
or
444+
exists(DataFlow::CallNode mapSeries |
445+
mapSeries = DataFlow::moduleMember("bluebird", "mapSeries").getACall()
446+
|
447+
// from `xs` to `x` in `require("bluebird").mapSeries(xs, (x) => {...})`.
448+
pred = mapSeries.getArgument(0) and
449+
succ = mapSeries.getABoundCallbackParameter(1, 0)
450+
or
451+
// from `y` to `require("bluebird").mapSeries(x, x => y)`.
452+
pred = mapSeries.getCallback(1).getAReturn() and
453+
succ = mapSeries
454+
)
443455
}
444456

445457
/**

javascript/ql/test/library-tests/Promises/flow.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,15 @@
154154
} catch (e) {
155155
sink(e); // NOT OK
156156
}
157-
})();
157+
})();
158+
159+
(function () {
160+
var source = "source";
161+
162+
var bluebird = require("bluebird");
163+
164+
bluebird.mapSeries(source, x => sink(x)); // NOT OK (for taint-tracking configs)
165+
166+
const foo = bluebird.mapSeries(source, x => x);
167+
sink(foo); // NOT OK (for taint-tracking configs)
168+
})

javascript/ql/test/library-tests/Promises/tests.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ flow
237237
exclusiveTaintFlow
238238
| flow2.js:2:15:2:22 | "source" | flow2.js:20:7:20:14 | tainted3 |
239239
| flow.js:136:15:136:22 | "source" | flow.js:141:7:141:13 | async() |
240+
| flow.js:160:15:160:22 | "source" | flow.js:164:39:164:39 | x |
241+
| flow.js:160:15:160:22 | "source" | flow.js:167:7:167:9 | foo |
240242
| interflow.js:3:18:3:25 | "source" | interflow.js:18:10:18:14 | error |
241243
typetrack
242244
| flow2.js:4:2:4:31 | Promise ... lean"]) | flow2.js:4:14:4:30 | [source, "clean"] | copy $PromiseResolveField$ |

0 commit comments

Comments
 (0)