
Robert (Community Member) asked a question.
Just wanted to post this one to see if anyone had any suggestions (other than schedule a consultation, or mark as "Mitigated: False Positive"):
Code:
function calculateMainContainerSize() {
var offset = 0;
var elements = $('#page-search-container, #claim-info-header');
elements.each(function (index, e) {
var element = $(e); // line 50
if (element.length && element.outerHeight() !== null) {
offset += element.outerHeight();
}
});
return 'calc(100vh - ' + offset + 'px)';
}
Flaw: on line 50, "var element = $(e);"
CWE-80: This call to jQuery() contains a cross-site scripting (XSS) flaw. ....etc....
Screenshot showing it on the triage flaws page:
.png)
Hi @Robert (Community Member) ,
Unfortunately, both look like false positives. Have you scanned this on the latest version of Veracode Static Analysis? We have recently made significant improvements to our JavaScript modelling.
I would recommend you contact our technical support team. Here's how you can log a case:
1. Navigate to the upper right corner of any page in the Community, click on your user avatar.
2. Select Contact Support from the drop-down menu.
Typically, we don't recommend making code changes to workaround false positive issues, rather we'd recommend documenting this in a mitigation. However, as you requested alternatives you could consider rewriting the functionality without jQuery to something like this:
function calculateMainContainerSizeSansJQuery() {
let offset = 0;
[
document.getElementById('page-search-container'),
document.getElementById('claim-info-header')
].forEach((e) => {
var element = $(e); // line 50
if (element.length && element.outerHeight() !== null) {
offset += element.outerHeight();
}
})
return 'calc(100vh - ' + offset + 'px)';
}
This is an excellent resource to learn more about jQuery alternatives: http://youmightnotneedjquery.com .
Thank you,
Boy Baukema