So, when our web application is scanned for Veracode, I get many Cross-Site Scripting flaws,
"Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)"(CWE ID 80).
And, out of few flaws we have, I could not figure out how to fix this particular scenario.
Below is my piece of code -
$(".ui-dialog-buttonset .ui-button:visible").each(function(index, item) {
var label = $(item).text();
if (label == "Save" || label == "Create")
$(item).click();
});
I can see flaw reported on $(item).text();
and $(item).click();
lines.
I understand that, for text I can use something like DOMPurify.sanitize
to clean the string.
But, I could not understand, why veracode is reporting for $(item).click();
Is it because the $(item)
itself is not safe?
If yes then, how do I fix it?
I would greatly appreciate any help in this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…