Skip to content

Commit f13a4f5

Browse files
committed
require that the plugin and sink are in the same toplevel
1 parent d47c852 commit f13a4f5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

javascript/ql/src/semmle/javascript/security/dataflow/UnsafeJQueryPluginCustomizations.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ module UnsafeJQueryPlugin {
177177
*/
178178
class AmbiguousHtmlOrSelectorArgumentAsSink extends Sink {
179179
AmbiguousHtmlOrSelectorArgumentAsSink() {
180-
this instanceof AmbiguousHtmlOrSelectorArgument and not isLikelyIntentionalHtmlSink(_, this)
180+
this instanceof AmbiguousHtmlOrSelectorArgument and not isLikelyIntentionalHtmlSink(this)
181181
}
182182
}
183183

@@ -191,15 +191,16 @@ module UnsafeJQueryPlugin {
191191
}
192192

193193
/**
194-
* Holds if `plugin` likely expects `sink` to be treated as a HTML fragment.
194+
* Holds if there exists a jQuery plugin that likely expects `sink` to be treated as a HTML fragment.
195195
*/
196-
predicate isLikelyIntentionalHtmlSink(JQuery::JQueryPluginMethod plugin, DataFlow::Node sink) {
197-
exists(DataFlow::PropWrite defaultDef, string default, DataFlow::PropRead finalRead |
196+
predicate isLikelyIntentionalHtmlSink(DataFlow::Node sink) {
197+
exists(JQuery::JQueryPluginMethod plugin, DataFlow::PropWrite defaultDef, string default, DataFlow::PropRead finalRead |
198198
hasDefaultOption(plugin, defaultDef) and
199199
defaultDef.getPropertyName() = finalRead.getPropertyName() and
200200
defaultDef.getRhs().mayHaveStringValue(default) and
201201
default.regexpMatch("\\s*<.*") and
202-
finalRead.flowsTo(sink)
202+
finalRead.flowsTo(sink) and
203+
sink.getTopLevel() = plugin.getTopLevel()
203204
)
204205
}
205206
}

0 commit comments

Comments
 (0)