Skip to content

Commit 28cfe54

Browse files
authored
Merge pull request github#3325 from erik-krogh/MoreEventClasses
Approved by asgerf
2 parents 671e7c6 + 6ada588 commit 28cfe54

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,14 @@ module ClassNode {
11961196
getAPropertySource("prototype") = newCall and
11971197
result = newCall.getCalleeNode()
11981198
)
1199+
or
1200+
// util.inherits(C, D);
1201+
exists(DataFlow::CallNode inheritsCall |
1202+
inheritsCall = DataFlow::moduleMember("util", "inherits").getACall()
1203+
|
1204+
this = inheritsCall.getArgument(0).getALocalSource() and
1205+
result = inheritsCall.getArgument(1)
1206+
)
11991207
}
12001208
}
12011209
}

javascript/ql/test/library-tests/frameworks/EventEmitter/test.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| customEmitter.js:18:15:18:20 | "baz2" | customEmitter.js:13:23:13:26 | data |
55
| customEmitter.js:21:15:21:20 | "baz3" | customEmitter.js:13:23:13:26 | data |
66
| customEmitter.js:21:15:21:20 | "baz3" | customEmitter.js:22:14:22:18 | yData |
7+
| tst2.js:18:16:18:20 | "bar" | tst2.js:17:14:17:16 | bar |
78
| tst.js:9:23:9:33 | 'FirstData' | tst.js:6:40:6:44 | first |
89
| tst.js:10:24:10:35 | 'SecondData' | tst.js:7:32:7:37 | second |
910
| tst.js:15:24:15:39 | 'OtherFirstData' | tst.js:14:41:14:50 | otherFirst |
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var util = require('util');
2+
var EventEmitter = require('events').EventEmitter;
3+
4+
var Connector = function() {
5+
if (!(this instanceof Connector)) {
6+
return new Connector(port, host, opts);
7+
}
8+
9+
EventEmitter.call(this);
10+
};
11+
12+
util.inherits(Connector, EventEmitter);
13+
14+
Connector.prototype.foo = function() {};
15+
16+
var em = new Connector();
17+
em.on("foo", bar => {});
18+
em.emit("foo", "bar");

0 commit comments

Comments
 (0)