I have the below js code
var a = window.location.href.substring(0,window.location.href.lastIndex('/')+1) + "logout.jsp";
setTimeout(function(){
window.location.href = a;
},1000);
When I am running a fortify scan for the above file, it is showing a security risk on the above line with Dynamic Code Evaluation :Code Injection. Now I am not able to understand on how to fix it. Do I need to add any encoder for window.href or how to resolve this. Also if we have encode , what I need to do.
If I understand the logic correctly, you are trying to get the path of the url without the page name, and then you intend to redirect to it.
If that is correct, you might be able to get it to work using,
It should in principal get rid of the vulnerability, but I am not fully sure if the tool detects any other vulnerability in it.