@@ -844,6 +844,12 @@ module ClassNode {
844844 override DataFlow:: Node getASuperClassNode ( ) { result = astNode .getSuperClass ( ) .flow ( ) }
845845 }
846846
847+ private DataFlow:: PropRef getAPrototypeReferenceInFile ( string name , File f ) {
848+ GlobalAccessPath:: getAccessPath ( result .getBase ( ) ) = name and
849+ result .getPropertyName ( ) = "prototype" and
850+ result .getFile ( ) = f
851+ }
852+
847853 /**
848854 * A function definition with prototype manipulation as a `ClassNode` instance.
849855 */
@@ -854,9 +860,16 @@ module ClassNode {
854860
855861 FunctionStyleClass ( ) {
856862 function .getFunction ( ) = astNode and
857- exists ( DataFlow:: PropRef read |
858- read .getPropertyName ( ) = "prototype" and
859- read .getBase ( ) .analyze ( ) .getAValue ( ) = function
863+ (
864+ exists ( DataFlow:: PropRef read |
865+ read .getPropertyName ( ) = "prototype" and
866+ read .getBase ( ) .analyze ( ) .getAValue ( ) = function
867+ )
868+ or
869+ exists ( string name |
870+ name = GlobalAccessPath:: fromRhs ( this ) and
871+ exists ( getAPrototypeReferenceInFile ( name , getFile ( ) ) )
872+ )
860873 )
861874 }
862875
@@ -916,11 +929,16 @@ module ClassNode {
916929 result = base .getAPropertyRead ( "prototype" )
917930 or
918931 result = base .getAPropertySource ( "prototype" )
919- or
920- exists ( ExtendCall call |
921- call .getDestinationOperand ( ) = base .getAPropertyRead ( "prototype" ) and
922- result = call .getASourceOperand ( )
923- )
932+ )
933+ or
934+ exists ( string name |
935+ GlobalAccessPath:: fromRhs ( this ) = name and
936+ result = getAPrototypeReferenceInFile ( name , getFile ( ) )
937+ )
938+ or
939+ exists ( ExtendCall call |
940+ call .getDestinationOperand ( ) = getAPrototypeReference ( ) and
941+ result = call .getASourceOperand ( )
924942 )
925943 }
926944
0 commit comments