bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

Feature proposal: Listen to and report `securitypolicyviolation` events

Open backus opened this issue 4 years ago • 5 comments

All major browsers support the SecurityPolicyViolationEvent:

document.addEventListener("securitypolicyviolation", (e) => {
  console.log(e.blockedURI);
  console.log(e.violatedDirective);
  console.log(e.originalPolicy);
});

The apps I'm working on are very strict and security conscious. We serve all of our requests with a strict CSP and use the report-to/report-uri feature to track violations. This is sort of annoying though, since the service we use to track this is separate from our main bug tracker (Bugsnag) and other monitoring tools.

We'll probably add our own listener to this event and pipe it to Bugsnag as an info notification, but I think it would also make sense for Bugsnag to add direct support for this. Right now I think we only get partial, less high quality, reporting of this with Bugsnag via it hooking console.error or exception handling

backus avatar Mar 02 '21 21:03 backus

Hey @backus, will put this to our product team for their consideration, thanks for raising! Like you say, in the meantime it's possible to add a listener and handle the error by calling Bugsnag.notify() with the information in the object that this event throws. Will keep you posted with any updates in this thread.

xljones avatar Mar 11 '21 09:03 xljones

Is this making its way up the backlog? I’d also love seeing built-in CSP violation reporting support in Bugsnag.

Haraldson avatar Jun 20 '22 12:06 Haraldson

Hi @Haraldson,

This is still on our backlog, higher priority items have meant we have not yet got round to this. So unfortunately we don't yet have a good idea in terms of timeframes doing this work. We will update here as soon as we do.

johnkiely1 avatar Jun 21 '22 09:06 johnkiely1