Skip to content

Commit e9575c3

Browse files
committed
JS: Support AdditionalUseStep in API graphs
1 parent 4e68a46 commit e9575c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,23 @@ module API {
388388
API::Node getNode() { result = root().getASuccessor(Label::entryPoint(this)) }
389389
}
390390

391+
/**
392+
* A class for contributing new steps for tracking uses of an API.
393+
*/
394+
class AdditionalUseStep extends Unit {
395+
/**
396+
* Holds if use nodes should flow from `pred` to `succ`.
397+
*/
398+
predicate step(DataFlow::SourceNode pred, DataFlow::SourceNode succ) { none() }
399+
}
400+
401+
private module AdditionalUseStep {
402+
pragma[nomagic]
403+
predicate step(DataFlow::SourceNode pred, DataFlow::SourceNode succ) {
404+
any(AdditionalUseStep st).step(pred, succ)
405+
}
406+
}
407+
391408
/**
392409
* Provides the actual implementation of API graphs, cached for performance.
393410
*
@@ -751,6 +768,11 @@ module API {
751768
boundArgs in [0 .. 10]
752769
)
753770
or
771+
exists(DataFlow::SourceNode mid |
772+
mid = trackUseNode(nd, promisified, boundArgs, prop, t) and
773+
AdditionalUseStep::step(pragma[only_bind_out](mid), result)
774+
)
775+
or
754776
exists(DataFlow::Node pred, string preprop |
755777
trackUseNode(nd, promisified, boundArgs, preprop, t.continue()).flowsTo(pred) and
756778
promisified = false and

0 commit comments

Comments
 (0)