@@ -18,7 +18,7 @@ module UnsafeJQueryPlugin {
1818 /**
1919 * Gets the plugin that this source is used in.
2020 */
21- abstract JQueryPluginMethod getPlugin ( ) ;
21+ abstract JQuery :: JQueryPluginMethod getPlugin ( ) ;
2222 }
2323
2424 /**
@@ -49,49 +49,6 @@ module UnsafeJQueryPlugin {
4949 }
5050 }
5151
52- /**
53- * Holds for jQuery plugin definitions of the form `$.fn.<pluginName> = <plugin>`.
54- */
55- private predicate jQueryPluginDefinition ( string pluginName , DataFlow:: Node plugin ) {
56- exists ( DataFlow:: PropRead fn , DataFlow:: PropWrite write |
57- fn = jquery ( ) .getAPropertyRead ( "fn" ) and
58- (
59- write = fn .getAPropertyWrite ( )
60- or
61- exists ( ExtendCall extend , DataFlow:: SourceNode source |
62- fn .flowsTo ( extend .getDestinationOperand ( ) ) and
63- source = extend .getASourceOperand ( ) and
64- write = source .getAPropertyWrite ( )
65- )
66- ) and
67- plugin = write .getRhs ( ) and
68- (
69- pluginName = write .getPropertyName ( ) or
70- write .getPropertyNameExpr ( ) .flow ( ) .mayHaveStringValue ( pluginName )
71- )
72- )
73- }
74-
75- /**
76- * Gets a node that is registered as a jQuery plugin method at `def`.
77- */
78- private DataFlow:: SourceNode getAJQueryPluginMethod (
79- DataFlow:: TypeBackTracker t , DataFlow:: Node def
80- ) {
81- t .start ( ) and
82- jQueryPluginDefinition ( _, def ) and
83- result .flowsTo ( def )
84- or
85- exists ( DataFlow:: TypeBackTracker t2 | result = getAJQueryPluginMethod ( t2 , def ) .backtrack ( t2 , t ) )
86- }
87-
88- /**
89- * Gets a function that is registered as a jQuery plugin method at `def`.
90- */
91- private DataFlow:: FunctionNode getAJQueryPluginMethod ( DataFlow:: Node def ) {
92- result = getAJQueryPluginMethod ( DataFlow:: TypeBackTracker:: end ( ) , def )
93- }
94-
9552 /**
9653 * Gets an operand to `extend`.
9754 */
@@ -109,29 +66,10 @@ module UnsafeJQueryPlugin {
10966 result = getAnExtendOperand ( DataFlow:: TypeBackTracker:: end ( ) , extend )
11067 }
11168
112- /**
113- * A function that is registered as a jQuery plugin method.
114- */
115- class JQueryPluginMethod extends DataFlow:: FunctionNode {
116- string pluginName ;
117-
118- JQueryPluginMethod ( ) {
119- exists ( DataFlow:: Node def |
120- jQueryPluginDefinition ( pluginName , def ) and
121- this = getAJQueryPluginMethod ( def )
122- )
123- }
124-
125- /**
126- * Gets the name of this plugin.
127- */
128- string getPluginName ( ) { result = pluginName }
129- }
130-
13169 /**
13270 * Holds if `plugin` has a default option defined at `def`.
13371 */
134- private predicate hasDefaultOption ( JQueryPluginMethod plugin , DataFlow:: PropWrite def ) {
72+ private predicate hasDefaultOption ( JQuery :: JQueryPluginMethod plugin , DataFlow:: PropWrite def ) {
13573 exists ( ExtendCall extend , JQueryPluginOptions options , DataFlow:: SourceNode default |
13674 options .getPlugin ( ) = plugin and
13775 options = getAnExtendOperand ( extend ) and
@@ -144,7 +82,7 @@ module UnsafeJQueryPlugin {
14482 * The client-provided options object for a jQuery plugin.
14583 */
14684 class JQueryPluginOptions extends DataFlow:: ParameterNode {
147- JQueryPluginMethod method ;
85+ JQuery :: JQueryPluginMethod method ;
14886
14987 JQueryPluginOptions ( ) {
15088 exists ( string optionsPattern |
@@ -165,7 +103,7 @@ module UnsafeJQueryPlugin {
165103 /**
166104 * Gets the plugin method that these options are used in.
167105 */
168- JQueryPluginMethod getPlugin ( ) { result = method }
106+ JQuery :: JQueryPluginMethod getPlugin ( ) { result = method }
169107 }
170108
171109 /**
@@ -224,7 +162,9 @@ module UnsafeJQueryPlugin {
224162 * The client-provided options object for a jQuery plugin, considered as a source for unsafe jQuery plugins.
225163 */
226164 class JQueryPluginOptionsAsSource extends Source , JQueryPluginOptions {
227- override JQueryPluginMethod getPlugin ( ) { result = JQueryPluginOptions .super .getPlugin ( ) }
165+ override JQuery:: JQueryPluginMethod getPlugin ( ) {
166+ result = JQueryPluginOptions .super .getPlugin ( )
167+ }
228168 }
229169
230170 /**
@@ -246,7 +186,7 @@ module UnsafeJQueryPlugin {
246186 /**
247187 * Holds if `plugin` likely expects `sink` to be treated as a HTML fragment.
248188 */
249- predicate isLikelyIntentionalHtmlSink ( JQueryPluginMethod plugin , Sink sink ) {
189+ predicate isLikelyIntentionalHtmlSink ( JQuery :: JQueryPluginMethod plugin , Sink sink ) {
250190 exists ( DataFlow:: PropWrite defaultDef , string default , DataFlow:: PropRead finalRead |
251191 hasDefaultOption ( plugin , defaultDef ) and
252192 defaultDef .getPropertyName ( ) = finalRead .getPropertyName ( ) and
0 commit comments