Skip to content

Commit 8f41385

Browse files
committed
JS: Make other node types not depend on tracking predicates
1 parent 7fc8753 commit 8f41385

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,9 +753,31 @@ module API {
753753
or
754754
any(TypeAnnotation n).hasUnderlyingType(m, _)
755755
} or
756-
MkClassInstance(DataFlow::ClassNode cls) { needsDefNode(cls) } or
757-
MkDef(DataFlow::Node nd) { rhs(_, _, nd) } or
758-
MkUse(DataFlow::Node nd) { use(_, _, nd) } or
756+
MkClassInstance(DataFlow::ClassNode cls) or
757+
MkDef(DataFlow::Node nd) {
758+
nd = any(DataFlow::PropWrite w).getRhs()
759+
or
760+
nd = any(DataFlow::FunctionNode fn).getReturnNode()
761+
or
762+
nd = any(DataFlow::FunctionNode fn).getAReturn()
763+
or
764+
nd = any(DataFlow::FunctionNode fn).getExceptionalReturn()
765+
or
766+
nd = any(DataFlow::CallNode c).getReceiver()
767+
or
768+
nd = any(DataFlow::InvokeNode i).getAnArgument()
769+
or
770+
nd = any(DataFlow::InvokeNode i).getASpreadArgument()
771+
or
772+
nd = any(ThrowStmt stmt).getExpr().flow()
773+
or
774+
nd = any(ExportDeclaration decl).getDirectSourceNode(_)
775+
or
776+
nd = any(MemberDeclaration m).getInit().flow()
777+
or
778+
nd = any(ClassDefinition cls | exists(cls.getADecorator())).flow()
779+
} or
780+
MkUse(DataFlow::Node nd) { nd instanceof DataFlow::SourceNode } or
759781
/** A use of a TypeScript type. */
760782
MkTypeUse(string moduleName, string exportName) {
761783
any(TypeAnnotation n).hasUnderlyingType(moduleName, exportName)
@@ -984,6 +1006,7 @@ module API {
9841006
predicate rhs(TApiNode nd, DataFlow::Node rhs) {
9851007
exists(string m | nd = MkModuleExport(m) | exports(m, rhs))
9861008
or
1009+
rhs(_, _, rhs) and
9871010
nd = MkDef(rhs)
9881011
}
9891012

@@ -1246,6 +1269,7 @@ module API {
12461269
ref = cls.(DataFlow::ClassNode).getAPrototypeReference()
12471270
)
12481271
or
1272+
use(_, _, ref) and
12491273
nd = MkUse(ref)
12501274
}
12511275

0 commit comments

Comments
 (0)