Skip to content

Commit d96f29d

Browse files
committed
JS: Disallow return steps in getASinkNode
1 parent 51bed86 commit d96f29d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

javascript/ql/lib/semmle/javascript/endpoints/EndpointNaming.qll

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,24 @@ private predicate sinkHasAlias(API::Node sink, string package, string name) {
185185
)
186186
}
187187

188+
/** Gets a source node that can flow to `sink` without using a return step. */
189+
private DataFlow::SourceNode nodeReachingSink(API::Node sink, DataFlow::TypeBackTracker t) {
190+
t.start() and
191+
result = sink.asSink().getALocalSource()
192+
or
193+
exists(DataFlow::TypeBackTracker t2 |
194+
result = nodeReachingSink(sink, t2).backtrack(t2, t) and
195+
t.hasReturn() = false
196+
)
197+
}
198+
199+
/** Gets a source node that can flow to `sink` without using a return step. */
200+
DataFlow::SourceNode nodeReachingSink(API::Node sink) {
201+
result = nodeReachingSink(sink, DataFlow::TypeBackTracker::end())
202+
}
203+
188204
/** Gets a sink node reachable from `node`. */
189-
bindingset[node]
190-
private API::Node getASinkNode(DataFlow::SourceNode node) { result.getAValueReachingSink() = node }
205+
private API::Node getASinkNode(DataFlow::SourceNode node) { node = nodeReachingSink(result) }
191206

192207
/**
193208
* Holds if `node` is a declaration in an externs file.

0 commit comments

Comments
 (0)