Skip to content

Commit 1d1149f

Browse files
committed
JS: Test and QLDoc for RxJS model
1 parent 144d04f commit 1d1149f

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ private class RxJsSubscribeStep extends TaintTracking::AdditionalTaintStep, Data
1717
}
1818

1919
/**
20-
* Holds if a tainted value sent into the given `pipe` should propagate to `arg`.
20+
* Gets a data flow node that can take the value of any input sent to `pipe`.
21+
*
22+
* For example, in `map(x => ...)`, `x` refers to any value sent to the pipe
23+
* created by the `map` call.
2124
*/
2225
private DataFlow::Node pipeInput(DataFlow::CallNode pipe) {
2326
pipe = DataFlow::moduleMember("rxjs/operators", ["map", "filter"]).getACall() and
2427
result = pipe.getCallback(0).getParameter(0)
2528
}
2629

2730
/**
28-
* Holds if a tainted value in `output` should propagate to the output of the given pipe.
31+
* Gets a data flow node whose value becomes the output of the given `pipe`.
32+
*
33+
* For example, in `map(x => x + 1)`, the `x + 1` node becomes the output of
34+
* the pipe.
2935
*/
3036
private DataFlow::Node pipeOutput(DataFlow::CallNode pipe) {
3137
pipe = DataFlow::moduleMember("rxjs/operators", "map").getACall() and

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ typeInferenceMismatch
9797
| promise.js:5:25:5:32 | source() | promise.js:5:8:5:33 | bluebir ... urce()) |
9898
| promise.js:10:24:10:31 | source() | promise.js:10:8:10:32 | Promise ... urce()) |
9999
| promise.js:12:20:12:27 | source() | promise.js:13:8:13:23 | resolver.promise |
100+
| rxjs.js:3:1:3:8 | source() | rxjs.js:10:14:10:17 | data |
100101
| sanitizer-function.js:12:17:12:24 | source() | sanitizer-function.js:14:10:14:14 | taint |
101102
| sanitizer-function.js:12:17:12:24 | source() | sanitizer-function.js:33:14:33:18 | taint |
102103
| sanitizer-guards.js:2:11:2:18 | source() | sanitizer-guards.js:4:8:4:8 | x |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { map, catchError } from 'rxjs/operators';
2+
3+
source()
4+
.pipe(
5+
map(x => x + 'foo'),
6+
map(x => x + 'bar'),
7+
catchError(err => {})
8+
)
9+
.subscribe(data => {
10+
sink(data)
11+
});

0 commit comments

Comments
 (0)