-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Hi,
I was analyzing the results of unsafe jquery plugin query and I found an interesting example.
First, here is a code snippet marked vulnerable in query tests
(function(){
$.fn.my_plugin = function my_plugin(element, options) {
this.$element = $(element);
this.options = $.extend({}, options);
if (this.options.parent) this.$parent = $(this.options.parent) // NOT OK
};
})
Here is (slightly modified) code I found in Collapse library which doesn't get marked as vulnerable
function ($) {
var Library = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, options)
if (this.options.parent) {this.$parent = $(this.options.parent)}}
}(window.jQuery);
Also note that in the second example, the if statement acts as a barrier guard and makes it safe. Please let me know if it is indeed safe (and how!) or if it is a false negative