Skip to content

Commit 6cbcc7a

Browse files
committed
add steps for next() call in RxJS
1 parent 2cbad4a commit 6cbcc7a

File tree

1 file changed

+41
-0
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,44 @@ private class RxJsPipeMapStep extends TaintTracking::SharedTaintStep {
102102
)
103103
}
104104
}
105+
106+
/**
107+
* Gets a instance of the `Subject` class from RxJS.
108+
*/
109+
private API::Node getARxJSSubject() {
110+
result =
111+
API::moduleImport("rxjs")
112+
.getMember(["Subject", "BehaviorSubject", "ReplaySubject", "AsyncSubject"])
113+
.getInstance()
114+
or
115+
result =
116+
API::Node::ofType("rxjs", ["Subject", "BehaviorSubject", "ReplaySubject", "AsyncSubject"])
117+
}
118+
119+
/**
120+
* A step from a call to the `next` method of a `Subject` to a read of the value.
121+
*/
122+
private class RxJSNextStep extends DataFlow::SharedFlowStep {
123+
override predicate storeStep(DataFlow::Node pred, DataFlow::SourceNode succ, string prop) {
124+
exists(API::CallNode call |
125+
call = getARxJSSubject().getMember("next").getACall() and
126+
pred = call.getArgument(0) and
127+
succ = call.getReceiver().getALocalSource() and
128+
prop = "value"
129+
)
130+
}
131+
132+
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
133+
exists(API::Node subject |
134+
subject = getARxJSSubject() and
135+
pred = subject.getMember("next").getACall().getArgument(0) and
136+
succ =
137+
subject
138+
.getMember("subscribe")
139+
.getParameter(0)
140+
.getMember("next")
141+
.getParameter(0)
142+
.getAnImmediateUse()
143+
)
144+
}
145+
}

0 commit comments

Comments
 (0)