@@ -497,24 +497,11 @@ module JQuery {
497
497
}
498
498
}
499
499
500
- /**
501
- * Gets a node that is written to `$.fn[something]`.
502
- * JQuery plugins are registered this way.
503
- */
504
- private DataFlow:: Node getAFnWrite ( ) {
505
- exists ( DataFlow:: PropWrite write , DataFlow:: PropRead jQueryFN |
506
- write .getBase ( ) = jQueryFN and
507
- jQueryFN .getBase ( ) .getALocalSource ( ) = JQuery:: dollar ( ) and
508
- jQueryFN .getPropertyName ( ) = "fn" and
509
- result = write .getRhs ( )
510
- )
511
- }
512
-
513
500
/**
514
501
* Gets a node that is backtracked from a node written to `$.fn[something]`.
515
502
*/
516
503
private DataFlow:: SourceNode writtenToJqueryFN ( DataFlow:: TypeBackTracker t ) {
517
- t .start ( ) and result = getAFnWrite ( ) .getALocalSource ( )
504
+ t .start ( ) and result = any ( DataFlow :: Node plugin | jQueryPluginDefinition ( _ , plugin ) ) .getALocalSource ( )
518
505
or
519
506
exists ( DataFlow:: TypeBackTracker t2 | result = writtenToJqueryFN ( t2 ) .backtrack ( t2 , t ) )
520
507
}
@@ -624,4 +611,27 @@ module JQuery {
624
611
node = getArgument ( 0 )
625
612
}
626
613
}
614
+
615
+ /**
616
+ * Holds for jQuery plugin definitions of the form `$.fn.<pluginName> = <plugin>`.
617
+ */
618
+ predicate jQueryPluginDefinition ( string pluginName , DataFlow:: Node plugin ) {
619
+ exists ( DataFlow:: PropRead fn , DataFlow:: PropWrite write |
620
+ fn = jquery ( ) .getAPropertyRead ( "fn" ) and
621
+ (
622
+ write = fn .getAPropertyWrite ( )
623
+ or
624
+ exists ( ExtendCall extend , DataFlow:: SourceNode source |
625
+ fn .flowsTo ( extend .getDestinationOperand ( ) ) and
626
+ source = extend .getASourceOperand ( ) and
627
+ write = source .getAPropertyWrite ( )
628
+ )
629
+ ) and
630
+ plugin = write .getRhs ( ) and
631
+ (
632
+ pluginName = write .getPropertyName ( ) or
633
+ write .getPropertyNameExpr ( ) .flow ( ) .mayHaveStringValue ( pluginName )
634
+ )
635
+ )
636
+ }
627
637
}
0 commit comments