Skip to content

Commit 307715a

Browse files
committed
JS: Use type resolution for CG augmentation
1 parent 57811ed commit 307715a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

javascript/ql/lib/semmle/javascript/Expr.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import javascript
66
private import semmle.javascript.internal.CachedStages
7+
private import semmle.javascript.internal.TypeResolution
78

89
/**
910
* A program element that is either an expression or a type annotation.
@@ -1017,7 +1018,11 @@ class InvokeExpr extends @invokeexpr, Expr {
10171018
* Note that the resolved function may be overridden in a subclass and thus is not
10181019
* necessarily the actual target of this invocation at runtime.
10191020
*/
1020-
Function getResolvedCallee() { result = this.getResolvedCalleeName().getImplementation() }
1021+
Function getResolvedCallee() {
1022+
TypeResolution::callTarget(this, result)
1023+
or
1024+
result = this.getResolvedCalleeName().getImplementation()
1025+
}
10211026
}
10221027

10231028
/**

javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module TypeResolution {
111111
member.(AST::ValueNode).flow(), contents)
112112
}
113113

114-
private predicate callTarget(InvokeExpr call, Function target) {
114+
predicate callTarget(InvokeExpr call, Function target) {
115115
exists(ClassDefinition cls |
116116
valueHasType(call.(NewExpr).getCallee(), trackClassValue(cls)) and
117117
target = cls.getConstructor().getBody()

0 commit comments

Comments
 (0)