I have a client side codebase that uses a number of third party npm modules. One of them, ag-charts-community as it happens, has a block that looks like this
function functionConstructorAvailable() {
try {
new Function("return true");
return true;
} catch (e) {
return false;
}
}
The module has its own internal logic for what to do if new Function
is not available, which it isn’t because my CSP doesn’t allow unsafe-eval
. I also have my CSP configured to report violations to my backend using report-uri
. Assuming that most attempts to call eval
are either bugs in my own team’s code, or some kind of attempted XSS attack, I want to know about them. But this particular error, even though it’s trapped and handled, also gets reported.
Is there a way to configure my policy so it doesn’t? Or do I need to somehow filter out these reports on the server that receives them?