java.lang.Object
org.htmlunit.html.csp.ContentSecurityPolicyViolation
- All Implemented Interfaces:
Serializable
The details of a violation of the Content-Security-Policy of a page.
The properties correspond to the ones of the securitypolicyviolation event
(see CSP - Violation Events).
- blockedUri: the blocked url; 'inline' for inline scripts, event handler attributes and javascript: urls, 'eval' for the evaluation of strings; only the scheme for urls without host (e.g. 'data'); for frame-ancestors the ancestor not allowed to embed the document
- effectiveDirective: the directive whose enforcement caused the violation (e.g. 'script-src-elem', 'script-src-attr', 'script-src', 'connect-src', 'frame-ancestors')
- sourceFile, lineNumber, columnNumber: the location of the code causing the violation; an empty string or 0 if not known
- sample: the first 40 characters of the blocked code if the directive contains 'report-sample', an empty string otherwise
- Author:
- Ronald Brill
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the blocked url.intReturns the column number in the source file.Returns the disposition of the violated policy ('enforce' or 'report').Returns the url of the document.Returns the directive whose enforcement caused the violation.intReturns the line number in the source file.Returns the policy (serialized) that was violated.Returns the sample of the blocked code.Returns the url of the source causing the violation.intReturns the http status code of the document.Returns the violated directive; same asgetEffectiveDirective().booleanReturns whether the violated policy is a report only policy (Content-Security-Policy-Report-Only header); in this case the action was not blocked.toString()
-
Constructor Details
-
ContentSecurityPolicyViolation
public ContentSecurityPolicyViolation(String documentUri, String blockedUri, String effectiveDirective, String originalPolicy, String sourceFile, String sample, int lineNumber, int columnNumber, int statusCode, boolean reportOnly) Ctor.- Parameters:
documentUri- the url of the documentblockedUri- the blocked urleffectiveDirective- the directive whose enforcement caused the violationoriginalPolicy- the policy (serialized) that was violatedsourceFile- the url of the source causing the violationsample- the sample of the blocked codelineNumber- the line number in the source filecolumnNumber- the column number in the source filestatusCode- the http status code of the documentreportOnly- whether the violated policy is a report only policy
-
-
Method Details
-
getDocumentUri
Returns the url of the document.- Returns:
- the url of the document
-
getBlockedUri
Returns the blocked url.- Returns:
- the blocked url
-
getEffectiveDirective
Returns the directive whose enforcement caused the violation.- Returns:
- the directive whose enforcement caused the violation
-
getOriginalPolicy
Returns the policy (serialized) that was violated.- Returns:
- the policy (serialized) that was violated
-
getSourceFile
Returns the url of the source causing the violation.- Returns:
- the url of the source causing the violation
-
getSample
Returns the sample of the blocked code.- Returns:
- the sample of the blocked code
-
getLineNumber
public int getLineNumber()Returns the line number in the source file.- Returns:
- the line number in the source file
-
getColumnNumber
public int getColumnNumber()Returns the column number in the source file.- Returns:
- the column number in the source file
-
getStatusCode
public int getStatusCode()Returns the http status code of the document.- Returns:
- the http status code of the document
-
getViolatedDirective
Returns the violated directive; same asgetEffectiveDirective().- Returns:
- the violated directive
-
isReportOnly
public boolean isReportOnly()Returns whether the violated policy is a report only policy (Content-Security-Policy-Report-Only header); in this case the action was not blocked.- Returns:
trueif the violated policy is a report only policy
-
getDisposition
Returns the disposition of the violated policy ('enforce' or 'report').- Returns:
- the disposition
-
toString
-