Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

fix Prototype_Pollution error from checkmarx

$
0
0

the word 'substring(1)' in line window.location.search.substring(1) get error Prototype_Pollution,Assigning external properties without validation may allow object properties pollution and affect application's normal behavior.how fix this code?

var QueryString = function () {// This function is anonymous, is executed immediately and // the return value is assigned to QueryString!var query_string = {};const allowed = new Set(['rqid','rowId','sid','RequestId','RequestTypeID','mode','id','requestIdList',]);var query = DOMPurify.sanitize(window.location.search.substring(1));var vars = query.split("&");for (var i = 0; i < vars.length; i++) {    var pair = vars[i].split("=");    // If first entry with this name    if (typeof query_string[pair[0]] === "undefined") {        if (allowed.has(pair[0])) {            query_string[pair[0]] = decodeURIComponent(pair[1]);        }        // If second entry with this name    } else if (typeof query_string[pair[0]] === "string") {        if (allowed.has(pair[0])) {            var arr = [query_string[pair[0]], decodeURIComponent(pair[1])];            query_string[pair[0]] = arr;        }        // If third or later entry with this name    } else {        if (allowed.has(pair[0])) {            query_string[pair[0]].push(decodeURIComponent(pair[1]));        }    }}return query_string;}();

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>