Skip to content

Commit 599e08d

Browse files
committed
JS: Add debug predicate for detecting lost edges/nodes
1 parent 04996c8 commit 599e08d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ module API {
811811
* Holds if `rhs` is the right-hand side of a definition of a node that should have an
812812
* incoming edge from `base` labeled `lbl` in the API graph.
813813
*/
814-
private predicate rhs(TApiNode base, Label::ApiLabel lbl, DataFlow::Node rhs) {
814+
predicate rhs(TApiNode base, Label::ApiLabel lbl, DataFlow::Node rhs) {
815815
hasSemantics(rhs) and
816816
(
817817
base = MkRoot() and
@@ -1047,7 +1047,7 @@ module API {
10471047
* Holds if `ref` is a use of a node that should have an incoming edge from `base` labeled
10481048
* `lbl` in the API graph.
10491049
*/
1050-
private predicate use(TApiNode base, Label::ApiLabel lbl, DataFlow::Node ref) {
1050+
predicate use(TApiNode base, Label::ApiLabel lbl, DataFlow::Node ref) {
10511051
hasSemantics(ref) and
10521052
(
10531053
base = MkRoot() and
@@ -1687,6 +1687,23 @@ module API {
16871687

16881688
import Cached
16891689

1690+
private module Debug {
1691+
query predicate missingDefNode(DataFlow::Node node) {
1692+
Stage1::rhs(_, _, node) and
1693+
not exists(MkDef(node))
1694+
}
1695+
1696+
query predicate missingUseNode(DataFlow::Node node) {
1697+
Stage1::use(_, _, node) and
1698+
not exists(MkUse(node))
1699+
}
1700+
1701+
query predicate lostEdge(Node pred, Label::ApiLabel lbl, Node succ) {
1702+
Stage1::edge(pred, lbl, succ) and
1703+
not Cached::edge(pred, lbl, succ)
1704+
}
1705+
}
1706+
16901707
/**
16911708
* Holds if there is an edge from `pred` to `succ` in the API graph.
16921709
*/

0 commit comments

Comments
 (0)