Skip to content

Commit d6578e1

Browse files
committed
JS: Handle constructor calls to avoid regression
1 parent 1b6cc4e commit d6578e1

File tree

1 file changed

+16
-5
lines changed
  • javascript/ql/src/semmle/javascript/dataflow/internal

1 file changed

+16
-5
lines changed

javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,23 @@ private module CachedSteps {
119119
predicate calls(DataFlow::InvokeNode invk, Function f) {
120120
f = invk.getACallee(0)
121121
or
122-
exists(DataFlow::ClassNode cls, string name |
123-
callResolvesToMember(invk, cls, name) and
124-
f = cls.getInstanceMethod(name).getFunction()
122+
exists(DataFlow::ClassNode cls |
123+
// Call to class member
124+
exists(string name |
125+
callResolvesToMember(invk, cls, name) and
126+
f = cls.getInstanceMethod(name).getFunction()
127+
or
128+
invk = cls.getAClassReference().getAMethodCall(name) and
129+
f = cls.getStaticMethod(name).getFunction()
130+
)
131+
or
132+
// Call to constructor
133+
invk = cls.getAClassReference().getAnInvocation() and
134+
f = cls.getConstructor().getFunction()
125135
or
126-
invk = cls.getAClassReference().getAMethodCall(name) and
127-
f = cls.getStaticMethod(name).getFunction()
136+
// Super call to constructor
137+
invk.asExpr().(SuperCall).getBinder() = cls.getConstructor().getFunction() and
138+
f = cls.getADirectSuperClass().getConstructor().getFunction()
128139
)
129140
or
130141
// Call from `foo.bar.baz()` to `foo.bar.baz = function()`

0 commit comments

Comments
 (0)