Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6fccf5a

Browse files
committed
use isLikelyIntentionalHtmlSink in the sink instead of in the where clause
1 parent 58f5189 commit 6fccf5a

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ from
2020
JQuery::JQueryPluginMethod plugin
2121
where
2222
cfg.hasFlowPath(source, sink) and
23-
source.getNode().(Source).getPlugin() = plugin and
24-
not isLikelyIntentionalHtmlSink(plugin, sink.getNode())
23+
source.getNode().(Source).getPlugin() = plugin
2524
select sink.getNode(), source, sink, "Potential XSS vulnerability in the $@.", plugin,
2625
"'$.fn." + plugin.getPluginName() + "' plugin"

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ module UnsafeJQueryPlugin {
171171
* An argument that may act as a HTML fragment rather than a CSS selector, as a sink for remote unsafe jQuery plugins.
172172
*/
173173
class AmbiguousHtmlOrSelectorArgumentAsSink extends Sink {
174-
AmbiguousHtmlOrSelectorArgumentAsSink() { this instanceof AmbiguousHtmlOrSelectorArgument }
174+
AmbiguousHtmlOrSelectorArgumentAsSink() {
175+
this instanceof AmbiguousHtmlOrSelectorArgument and not isLikelyIntentionalHtmlSink(_, this)
176+
}
175177
}
176178

177179
/**
@@ -186,7 +188,7 @@ module UnsafeJQueryPlugin {
186188
/**
187189
* Holds if `plugin` likely expects `sink` to be treated as a HTML fragment.
188190
*/
189-
predicate isLikelyIntentionalHtmlSink(JQuery::JQueryPluginMethod plugin, Sink sink) {
191+
predicate isLikelyIntentionalHtmlSink(JQuery::JQueryPluginMethod plugin, DataFlow::Node sink) {
190192
exists(DataFlow::PropWrite defaultDef, string default, DataFlow::PropRead finalRead |
191193
hasDefaultOption(plugin, defaultDef) and
192194
defaultDef.getPropertyName() = finalRead.getPropertyName() and

javascript/ql/test/query-tests/Security/CWE-079/unsafe-jquery-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
menu: '<div></div>',
104104
target: '.my_plugin'
105105
}, options);
106-
$(options.menu); // OK - but is flagged [INCONSISTENCY]
106+
$(options.menu); // OK
107107
$(options.target); // NOT OK
108108
};
109109

@@ -113,7 +113,7 @@
113113
};
114114
$.fn.my_plugin = function my_plugin(options) {
115115
options = $.extend({}, $.fn.my_plugin.defaults, options);
116-
$(options.menu); // OK - but is flagged [INCONSISTENCY]
116+
$(options.menu); // OK
117117
$(options.target); // NOT OK
118118
};
119119

0 commit comments

Comments
 (0)