Skip to content

Commit 7a3ecc7

Browse files
committed
JS: Fixup restriction of MkClassInstance
1 parent a975417 commit 7a3ecc7

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -778,17 +778,6 @@ module API {
778778
} or
779779
MkSyntheticCallbackArg(DataFlow::InvokeNode nd)
780780

781-
private predicate needsDefNode(DataFlow::ClassNode cls) {
782-
hasSemantics(cls) and
783-
(
784-
cls = trackDefNode(_)
785-
or
786-
cls.getAnInstanceReference() = trackDefNode(_)
787-
or
788-
needsDefNode(cls.getADirectSubClass())
789-
)
790-
}
791-
792781
class TDef = MkModuleDef or TNonModuleDef;
793782

794783
class TNonModuleDef = MkModuleExport or MkClassInstance or MkDef or MkSyntheticCallbackArg;
@@ -1235,6 +1224,21 @@ module API {
12351224
)
12361225
}
12371226

1227+
private predicate needsDefNode(DataFlow::ClassNode cls) {
1228+
hasSemantics(cls) and
1229+
(
1230+
cls = trackDefNode(_)
1231+
or
1232+
cls.getAnInstanceReference() = trackDefNode(_)
1233+
or
1234+
needsDefNode(cls.getADirectSubClass())
1235+
or
1236+
S::isAdditionalDefRoot(MkClassInstance(cls))
1237+
or
1238+
S::isAdditionalUseRoot(MkClassInstance(cls)) // These are also tracked as use-nodes
1239+
)
1240+
}
1241+
12381242
/**
12391243
* Holds if `ref` is a use of node `nd`.
12401244
*/
@@ -1258,12 +1262,12 @@ module API {
12581262
nd = MkModuleImport(m) and
12591263
ref = DataFlow::moduleImport(m)
12601264
)
1265+
)
1266+
or
1267+
exists(DataFlow::ClassNode cls | nd = MkClassInstance(cls) and needsDefNode(cls) |
1268+
ref = cls.getAReceiverNode()
12611269
or
1262-
exists(DataFlow::ClassNode cls | nd = MkClassInstance(cls) |
1263-
ref = cls.getAReceiverNode()
1264-
or
1265-
ref = cls.(DataFlow::ClassNode).getAPrototypeReference()
1266-
)
1270+
ref = cls.(DataFlow::ClassNode).getAPrototypeReference()
12671271
)
12681272
or
12691273
use(_, _, ref) and

0 commit comments

Comments
 (0)