ContentSecurityPolicyViolationReport Class

A violation of a content security policy (https://w3c.github.io/webappsec-csp/#violation), given to BrowsingContextOptions.ContentSecurityPolicyViolation. The URLs are stripped as in the reports sent to the endpoints of the policy (https://w3c.github.io/webappsec-csp/#strip-url-for-use-in-reports).

public sealed class ContentSecurityPolicyViolationReport

Properties

NameDescription
BlockedUrlGets the URL of the blocked resource, or a keyword such as inline, eval, wasm-eval, trusted-types-policy or trusted-types-sink.
ColumnNumberGets the column number in ContentSecurityPolicyViolationReport.SourceFile, or 0.
DispositionGets whether the violated policy is enforced (the resource is blocked) or report-only.
DocumentUrlGets the URL of the document (or of the response, for a violation of a navigation response check).
EffectiveDirectiveGets the directive whose enforcement caused the violation (e.g. img-src).
LineNumberGets the line number in ContentSecurityPolicyViolationReport.SourceFile, or 0.
OriginalPolicyGets the serialization of the violated policy.
ReferrerGets the referrer of the document, or the empty string.
SampleGets the sample of the code or of the value that caused the violation (only with the 'report-sample' source), or the empty string.
SourceFileGets the URL of the script that caused the violation, or null.
StatusCodeGets the HTTP status code of the response of the document.

Gets the URL of the blocked resource, or a keyword such as inline, eval, wasm-eval, trusted-types-policy or trusted-types-sink.

public string BlockedUrl { get; }

Property value

string

Gets the column number in ContentSecurityPolicyViolationReport.SourceFile, or 0.

public int ColumnNumber { get; }

Property value

int

Gets whether the violated policy is enforced (the resource is blocked) or report-only.

public SecurityPolicyViolationEventDisposition Disposition { get; }

Gets the URL of the document (or of the response, for a violation of a navigation response check).

public string DocumentUrl { get; }

Property value

string

Gets the directive whose enforcement caused the violation (e.g. img-src).

public string EffectiveDirective { get; }

Property value

string

public int LineNumber { get; }

Property value

int

Gets the serialization of the violated policy.

public string OriginalPolicy { get; }

Property value

string

Gets the referrer of the document, or the empty string.

public string Referrer { get; }

Property value

string

Gets the sample of the code or of the value that caused the violation (only with the 'report-sample' source), or the empty string.

public string Sample { get; }

Property value

string

Gets the URL of the script that caused the violation, or null.

public string? SourceFile { get; }

Property value

string?

Gets the HTTP status code of the response of the document.

public int StatusCode { get; }

Property value

int

Methods

NameDescription
ToString()Returns a string that represents the current object.

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.