Skip to content

Add securitypolicyviolation plugin #136

@xPaw

Description

@xPaw

I'm experimenting with something like this:

	document.addEventListener( 'securitypolicyviolation', ( e ) =>
	{
		if( !e.sourceFile.startsWith( location.origin ) )
		{
			return;
		}

		const error = new Error( `CSP Error ${e.violatedDirective}` );
		error.name = 'SecurityPolicyViolationError';

		Bugsnag.notify( error, {
			severity: 'info',
			metadata:
			{
				originalPolicy: e.originalPolicy,
				sourceFile: e.sourceFile,
				blockedURI: e.blockedURI
			}
		} );
	} );

This could be wrapped into a nicely formatted plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions