Skip to content

Commit b12d927

Browse files
committed
JS: Also expose "any state" version of tracking predicates
1 parent daf04f1 commit b12d927

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,13 @@ module API {
13841384
result = trackUseNode(nd, false, 0, "")
13851385
}
13861386

1387+
/**
1388+
* Gets a node whose forward tracking reaches `nd` in some state (e.g. possibly inside a content at this point).
1389+
*/
1390+
DataFlow::SourceNode trackUseNodeAnyState(DataFlow::SourceNode nd) {
1391+
result = trackUseNode(nd, _, _, _, _)
1392+
}
1393+
13871394
private DataFlow::SourceNode trackDefNode(DataFlow::Node nd, DataFlow::TypeBackTracker t) {
13881395
t.start() and
13891396
rhs(_, nd) and
@@ -1434,6 +1441,11 @@ module API {
14341441
result = trackDefNode(nd, DataFlow::TypeBackTracker::end())
14351442
}
14361443

1444+
/**
1445+
* Gets a node reached by the backwards tracking of `nd` in some state (e.g. possibly inside a content at this point).
1446+
*/
1447+
DataFlow::SourceNode trackDefNodeAnyState(DataFlow::Node nd) { result = trackDefNode(nd, _) }
1448+
14371449
private DataFlow::SourceNode awaited(DataFlow::InvokeNode call, DataFlow::TypeTracker t) {
14381450
t.startInPromise() and
14391451
trackUseNode(_, true, _, "").flowsTo(call.getCalleeNode()) and
@@ -1548,9 +1560,15 @@ module API {
15481560
DataFlow::SourceNode trackUseNode(DataFlow::SourceNode nd) =
15491561
forceLocal(Stage1::trackUseNode/1)(nd, result)
15501562

1563+
DataFlow::SourceNode trackUseNodeAnyState(DataFlow::SourceNode nd) =
1564+
forceLocal(Stage1::trackUseNodeAnyState/1)(nd, result)
1565+
15511566
DataFlow::SourceNode trackDefNode(DataFlow::SourceNode nd) =
15521567
forceLocal(Stage1::trackDefNode/1)(nd, result)
15531568

1569+
DataFlow::SourceNode trackDefNodeAnyState(DataFlow::Node nd) =
1570+
forceLocal(Stage1::trackDefNodeAnyState/1)(nd, result)
1571+
15541572
predicate edge(TApiNode pred, Label::ApiLabel lbl, TApiNode succ) =
15551573
forceLocal(Stage1::edge/3)(pred, lbl, succ)
15561574

0 commit comments

Comments
 (0)