/// <summary> /// Handles the Content Security Policy (CSP) violation errors. For more information see FilterConfig. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="CspViolationReportEventArgs"/> instance containing the event data.</param> protected void NWebsecHttpHeaderSecurityModule_CspViolationReported(object sender, CspViolationReportEventArgs e) { // Log the Content Security Policy (CSP) violation. CspViolationException exception = new CspViolationException(e.ViolationReport); DependencyResolver.Current.GetService <ILoggingService>().Log(exception); }
/// <summary> /// Handles the Content Security Policy (CSP) violation errors. For more information see FilterConfig. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="CspViolationReportEventArgs"/> instance containing the event data.</param> protected void NWebsecHttpHeaderSecurityModule_CspViolationReported(object sender, CspViolationReportEventArgs e) { var violationReport = e.ViolationReport; var reportDetails = violationReport.Details; var violationReportString = $"UserAgent:<{violationReport.UserAgent}>\r\nBlockedUri:<{reportDetails.BlockedUri}>\r\nColumnNumber:<{reportDetails.ColumnNumber}>\r\nDocumentUri:<{reportDetails.DocumentUri}>\r\nEffectiveDirective:<{reportDetails.EffectiveDirective}>\r\nLineNumber:<{reportDetails.LineNumber}>\r\nOriginalPolicy:<{reportDetails.OriginalPolicy}>\r\nReferrer:<{reportDetails.Referrer}>\r\nScriptSample:<{reportDetails.ScriptSample}>\r\nSourceFile:<{reportDetails.SourceFile}>\r\nStatusCode:<{reportDetails.StatusCode}>\r\nViolatedDirective:<{reportDetails.ViolatedDirective}>"; var exception = new CspViolationException(violationReportString); ErrorSignal.FromCurrentContext().Raise(exception, HttpContext.Current); }
/// <summary> /// Handles the Content Security Policy (CSP) violation errors. For more information see FilterConfig. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="CspViolationReportEventArgs"/> instance containing the event data.</param> protected void NWebsecHttpHeaderSecurityModule_CspViolationReported(object sender, CspViolationReportEventArgs e) { // Log the Content Security Policy (CSP) violation. CspViolationReport violationReport = e.ViolationReport; CspReportDetails reportDetails = violationReport.Details; string violationReportString = string.Format( "UserAgent:<{0}>\r\nBlockedUri:<{1}>\r\nColumnNumber:<{2}>\r\nDocumentUri:<{3}>\r\nEffectiveDirective:<{4}>\r\nLineNumber:<{5}>\r\nOriginalPolicy:<{6}>\r\nReferrer:<{7}>\r\nScriptSample:<{8}>\r\nSourceFile:<{9}>\r\nStatusCode:<{10}>\r\nViolatedDirective:<{11}>", violationReport.UserAgent, reportDetails.BlockedUri, reportDetails.ColumnNumber, reportDetails.DocumentUri, reportDetails.EffectiveDirective, reportDetails.LineNumber, reportDetails.OriginalPolicy, reportDetails.Referrer, reportDetails.ScriptSample, reportDetails.SourceFile, reportDetails.StatusCode, reportDetails.ViolatedDirective); CspViolationException exception = new CspViolationException(violationReportString); //DependencyResolver.Current.GetService<ILogService>().Log(exception); }