File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
src/semmle/javascript/dataflow
test/library-tests/frameworks/EventEmitter Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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 |
Original file line number Diff line number Diff line change 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" ) ;
You can’t perform that action at this time.
0 commit comments