File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
src/semmle/javascript/dataflow
test/library-tests/CallGraphs/AnnotatedTest Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -715,6 +715,15 @@ class ClassNode extends DataFlow::SourceNode {
715715 t .start ( ) and
716716 result = getAReceiverNode ( )
717717 or
718+ result = getAnInstanceReferenceAux ( t ) and
719+ // Avoid tracking into the receiver of other classes.
720+ // Note that this also blocks flows into a property of the receiver,
721+ // but the `localFieldStep` rule will often compensate for this.
722+ not result = any ( DataFlow:: ClassNode cls ) .getAReceiverNode ( )
723+ }
724+
725+ pragma [ noinline]
726+ private DataFlow:: SourceNode getAnInstanceReferenceAux ( DataFlow:: TypeTracker t ) {
718727 exists ( DataFlow:: TypeTracker t2 |
719728 result = getAnInstanceReference ( t2 ) .track ( t2 , t )
720729 )
Original file line number Diff line number Diff line change 1+ import 'dummy' ;
2+
3+ class Foo {
4+ a ( ) {
5+ /** calls:Foo.b */
6+ this . b ( ) ;
7+ }
8+
9+ /** name:Foo.b */
10+ b ( ) { }
11+ }
12+
13+ class Bar {
14+ a ( ) {
15+ /** calls:Bar.b */
16+ this . b ( ) ;
17+ }
18+
19+ /** name:Bar.b */
20+ b ( ) { }
21+ }
22+
23+ function callA ( x ) {
24+ x . a ( ) ;
25+ }
26+ callA ( new Foo ) ;
27+ callB ( new Bar ) ;
You can’t perform that action at this time.
0 commit comments