问题描述
我将SonarQube扫描用于ASP.NET MVC项目以进行代码质量检查。 SonarQube显示了项目中使用的一个JavaScript库的漏洞错误。 即-datepicker.js
下面是datepicker.js中的代码-
(function(){
var cache = {};
this.tmpl = function tmpl(str,data){
// figure out if we're getting a template,or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};" +
// Introduce the data as local variables using with(){}
"with(obj){p.push('" +
// Convert the template into pure JavaScript
str
.replace(/[\r\t\n]/g," ")
.split("<%").join("\t")
.replace(/((^|%>)[^\t]*)'/g,"$1\r")
.replace(/\t=(.*?)%>/g,"',$1,'")
.split("\t").join("');")
.split("%>").join("p.push('")
.split("\r").join("\\'")
+ "');}return p.join('');");
// Provide some basic currying to the user
return data ? fn( data ) : fn;
};
})
new Function("obj",arguments);};" +
// Introduce the data as local variables using with(){}
解决方案-它也提供了解决方案。它说,您应该使用ECMAScript 5的内置JSON函数或专用库。
链接-https://rules.sonarsource.com/javascript/RSPEC-3523
哪些替代方法可以代替新功能(“ param1”,“ param2”)通过声纳扫描?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)