Changeset 286150 in webkit
- Timestamp:
- Nov 24, 2021 8:20:55 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/script-sample-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/script-sample-no-opt-in-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/style-sample-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicy.cpp (modified) (16 diffs)
-
Source/WebCore/page/csp/ContentSecurityPolicy.h (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicyClient.h (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicySourceList.h (modified) (2 diffs)
-
Source/WebCore/page/csp/ContentSecurityPolicySourceListDirective.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r286146 r286150 1 2021-11-24 Patrick Griffis <pgriffis@igalia.com> 2 3 CSP: Implement submitting samples in violation reports 4 https://bugs.webkit.org/show_bug.cgi?id=233398 5 6 Reviewed by Kate Cheney. 7 8 Update expectations with more passes. 9 10 * web-platform-tests/content-security-policy/securitypolicyviolation/script-sample-expected.txt: 11 * web-platform-tests/content-security-policy/securitypolicyviolation/script-sample-no-opt-in-expected.txt: 12 * web-platform-tests/content-security-policy/securitypolicyviolation/style-sample-expected.txt: 13 1 14 2021-11-24 Manuel Rego Casasnovas <rego@igalia.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/script-sample-expected.txt
r259900 r286150 1 CONSOLE MESSAGE: The source list for Content Security Policy directive 'script-src' contains an invalid source: ''report-sample''. It will be ignored.2 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.3 CONSOLE MESSAGE: Refused to execute a script for an inline event handler because 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.4 CONSOLE MESSAGE: The source list for Content Security Policy directive 'script-src' contains an invalid source: ''report-sample''. It will be ignored.5 CONSOLE MESSAGE: The source list for Content Security Policy directive 'script-src' contains an invalid source: ''report-sample''. It will be ignored.6 CONSOLE MESSAGE: Refused to execute a script because 'unsafe-eval' does not appear in the script-src directive of the Content Security Policy.7 CONSOLE MESSAGE: Refused to execute a script because 'unsafe-eval' does not appear in the script-src directive of the Content Security Policy.8 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.9 1 10 2 11 3 Harness Error (TIMEOUT), message = null 12 4 13 TIMEOUT Inline script should have a sample. Test timed out 14 TIMEOUT Inline event handlers should have a sample. Test timed out 5 PASS Inline script should have a sample. 6 PASS Inline event handlers should have a sample. 15 7 TIMEOUT JavaScript URLs in iframes should have a sample. Test timed out 16 8 TIMEOUT eval() should have a sample. Test timed out -
trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/script-sample-no-opt-in-expected.txt
r259900 r286150 1 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.2 CONSOLE MESSAGE: Refused to execute a script for an inline event handler because 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.3 CONSOLE MESSAGE: Refused to execute a script because 'unsafe-eval' does not appear in the script-src directive of the Content Security Policy.4 CONSOLE MESSAGE: Refused to execute a script because 'unsafe-eval' does not appear in the script-src directive of the Content Security Policy.5 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.6 1 7 2 8 3 Harness Error (TIMEOUT), message = null 9 4 10 TIMEOUT Inline script should not have a sample. Test timed out 11 TIMEOUT Inline event handlers should not have a sample. Test timed out 5 PASS Inline script should not have a sample. 6 PASS Inline event handlers should not have a sample. 12 7 TIMEOUT JavaScript URLs in iframes should not have a sample. Test timed out 13 TIMEOUT eval()-alikes should not have a sample. Test timed out 8 PASS eval()-alikes should not have a sample. 14 9 -
trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/style-sample-expected.txt
r286136 r286150 1 1 2 FAIL Inline style blocks should have a sample. assert_equals: expected "p { omg: yay !important; }" but got "" 3 FAIL Inline style attributes should have a sample. assert_equals: expected "omg: yay !important;" but got "" 2 PASS Inline style blocks should have a sample. 3 PASS Inline style attributes should have a sample. 4 4 -
trunk/Source/WebCore/ChangeLog
r286148 r286150 1 2021-11-24 Patrick Griffis <pgriffis@igalia.com> 2 3 CSP: Implement submitting samples in violation reports 4 https://bugs.webkit.org/show_bug.cgi?id=233398 5 6 Reviewed by Kate Cheney. 7 8 This implements handling 'report-sample' directive and submits a sample 9 for style-src and script-src. It doesn't currently extract the source 10 from eval() yet. 11 12 * page/csp/ContentSecurityPolicy.cpp: 13 (WebCore::ContentSecurityPolicy::allowJavaScriptURLs const): 14 (WebCore::ContentSecurityPolicy::allowInlineEventHandlers const): 15 (WebCore::ContentSecurityPolicy::allowNonParserInsertedScripts const): 16 (WebCore::ContentSecurityPolicy::allowInlineScript const): 17 (WebCore::ContentSecurityPolicy::allowInlineStyle const): 18 (WebCore::ContentSecurityPolicy::allowFrameAncestors const): 19 (WebCore::ContentSecurityPolicy::allowPluginType const): 20 (WebCore::ContentSecurityPolicy::allowObjectFromSource const): 21 (WebCore::ContentSecurityPolicy::allowChildFrameFromSource const): 22 (WebCore::ContentSecurityPolicy::allowResourceFromSource const): 23 (WebCore::ContentSecurityPolicy::allowConnectToSource const): 24 (WebCore::ContentSecurityPolicy::allowBaseURI const): 25 (WebCore::ContentSecurityPolicy::reportViolation const): 26 * page/csp/ContentSecurityPolicy.h: 27 * page/csp/ContentSecurityPolicyClient.h: 28 * page/csp/ContentSecurityPolicyDirectiveList.cpp: 29 (WebCore::ContentSecurityPolicyDirectiveList::shouldReportSample const): 30 * page/csp/ContentSecurityPolicyDirectiveList.h: 31 * page/csp/ContentSecurityPolicySourceList.cpp: 32 (WebCore::ContentSecurityPolicySourceList::parseSource): 33 * page/csp/ContentSecurityPolicySourceList.h: 34 (WebCore::ContentSecurityPolicySourceList::shouldReportSample const): 35 * page/csp/ContentSecurityPolicySourceListDirective.h: 36 (WebCore::ContentSecurityPolicySourceListDirective::shouldReportSample const): 37 1 38 2021-11-24 Ziran Sun <zsun@igalia.com> 2 39 -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
r286136 r286150 407 407 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, URL(), "Refused to execute a script", "its hash, its nonce, or 'unsafe-inline'"); 408 408 // FIXME (rdar://83332874) implement scriptSrcElem properly. 409 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrcElem, violatedDirective, "inline"_s, consoleMessage, contextURL, TextPosition(contextLine, OrdinalNumber()));409 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrcElem, violatedDirective, "inline"_s, consoleMessage, contextURL, source, TextPosition(contextLine, OrdinalNumber())); 410 410 if (!didNotifyInspector && violatedDirective.directiveList().isReportOnly()) { 411 411 reportBlockedScriptExecutionToInspector(violatedDirective.text()); … … 424 424 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 425 425 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, URL(), "Refused to execute a script for an inline event handler", "'unsafe-inline'"); 426 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, "inline"_s, consoleMessage, contextURL, TextPosition(contextLine, OrdinalNumber()), URL(), nullptr, element);426 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, "inline"_s, consoleMessage, contextURL, source, TextPosition(contextLine, OrdinalNumber()), URL(), nullptr, element); 427 427 if (!didNotifyInspector && !violatedDirective.directiveList().isReportOnly()) { 428 428 reportBlockedScriptExecutionToInspector(violatedDirective.text()); … … 475 475 TextPosition sourcePosition(OrdinalNumber::beforeFirst(), OrdinalNumber()); 476 476 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, url, "Refused to load"); 477 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrcElem, violatedDirective, url.string(), consoleMessage, String(), s ourcePosition);477 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrcElem, violatedDirective, url.string(), consoleMessage, String(), scriptContent, sourcePosition); 478 478 }; 479 479 … … 488 488 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 489 489 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, URL(), "Refused to execute a script", "its hash, its nonce, or 'unsafe-inline'"); 490 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, "inline"_s, consoleMessage, contextURL, TextPosition(contextLine, OrdinalNumber()), URL(), nullptr, &element);490 reportViolation(ContentSecurityPolicyDirectiveNames::scriptSrc, violatedDirective, "inline"_s, consoleMessage, contextURL, scriptContent, TextPosition(contextLine, OrdinalNumber()), URL(), nullptr, &element); 491 491 if (!didNotifyInspector && !violatedDirective.directiveList().isReportOnly()) { 492 492 reportBlockedScriptExecutionToInspector(violatedDirective.text()); … … 508 508 auto name = shouldCheckUnsafeHashes == CheckUnsafeHashes::Yes ? ContentSecurityPolicyDirectiveNames::styleSrcAttr : ContentSecurityPolicyDirectiveNames::styleSrcElem; 509 509 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::styleSrc, violatedDirective, URL(), "Refused to apply a stylesheet", "its hash, its nonce, or 'unsafe-inline'"); 510 reportViolation(name, violatedDirective, "inline"_s, consoleMessage, contextURL, TextPosition(contextLine, OrdinalNumber()), URL(), nullptr, &element);510 reportViolation(name, violatedDirective, "inline"_s, consoleMessage, contextURL, styleContent, TextPosition(contextLine, OrdinalNumber()), URL(), nullptr, &element); 511 511 }; 512 512 … … 546 546 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 547 547 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::frameAncestors, violatedDirective, url, "Refused to load"); 548 reportViolation(ContentSecurityPolicyDirectiveNames::frameAncestors, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition);548 reportViolation(ContentSecurityPolicyDirectiveNames::frameAncestors, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 549 549 }; 550 550 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestor, frame); … … 574 574 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 575 575 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::frameAncestors, violatedDirective, url, "Refused to load"); 576 reportViolation(ContentSecurityPolicyDirectiveNames::frameAncestors, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition);576 reportViolation(ContentSecurityPolicyDirectiveNames::frameAncestors, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 577 577 }; 578 578 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestorOrigins, ancestorOrigins); … … 587 587 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 588 588 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::pluginTypes, violatedDirective, url, "Refused to load", "its MIME type"); 589 reportViolation(ContentSecurityPolicyDirectiveNames::pluginTypes, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition);589 reportViolation(ContentSecurityPolicyDirectiveNames::pluginTypes, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 590 590 }; 591 591 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForPluginType, type, typeAttribute); … … 603 603 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 604 604 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::objectSrc, violatedDirective, url, "Refused to load"); 605 reportViolation(ContentSecurityPolicyDirectiveNames::objectSrc, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition);605 reportViolation(ContentSecurityPolicyDirectiveNames::objectSrc, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 606 606 }; 607 607 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForObjectSource, url, redirectResponseReceived == RedirectResponseReceived::Yes, ContentSecurityPolicySourceListDirective::ShouldAllowEmptyURLIfSourceListIsNotNone::Yes); … … 617 617 const char* effectiveViolatedDirective = violatedDirective.name() == ContentSecurityPolicyDirectiveNames::frameSrc ? ContentSecurityPolicyDirectiveNames::frameSrc : ContentSecurityPolicyDirectiveNames::childSrc; 618 618 String consoleMessage = consoleMessageForViolation(effectiveViolatedDirective, violatedDirective, url, "Refused to load"); 619 reportViolation(effectiveViolatedDirective, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition);619 reportViolation(effectiveViolatedDirective, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 620 620 }; 621 621 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForFrame, url, redirectResponseReceived == RedirectResponseReceived::Yes); … … 631 631 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 632 632 String consoleMessage = consoleMessageForViolation(name, violatedDirective, blockedURL, "Refused to load"); 633 reportViolation(name, violatedDirective, blockedURL.string(), consoleMessage, sourceURL, sourcePosition);633 reportViolation(name, violatedDirective, blockedURL.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 634 634 }; 635 635 return allPoliciesAllow(WTFMove(handleViolatedDirective), resourcePredicate, url, redirectResponseReceived == RedirectResponseReceived::Yes); … … 684 684 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 685 685 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::connectSrc, violatedDirective, url, "Refused to connect to"); 686 reportViolation(ContentSecurityPolicyDirectiveNames::connectSrc, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition, preRedirectURL);686 reportViolation(ContentSecurityPolicyDirectiveNames::connectSrc, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition, preRedirectURL); 687 687 }; 688 688 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForConnectSource, url, redirectResponseReceived == RedirectResponseReceived::Yes); … … 704 704 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 705 705 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::baseURI, violatedDirective, url, "Refused to change the document base URL to"); 706 reportViolation(ContentSecurityPolicyDirectiveNames::baseURI, violatedDirective, url.string(), consoleMessage, sourceURL, sourcePosition);706 reportViolation(ContentSecurityPolicyDirectiveNames::baseURI, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition); 707 707 }; 708 708 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForBaseURI, url); … … 725 725 void ContentSecurityPolicy::reportViolation(const String& violatedDirective, const ContentSecurityPolicyDirective& effectiveViolatedDirective, const String& blockedURL, const String& consoleMessage, JSC::JSGlobalObject* state) const 726 726 { 727 // FIXME: Extract source file and sourceposition from JSC::ExecState.728 return reportViolation(violatedDirective, effectiveViolatedDirective.nameForReporting().convertToASCIILowercase(), effectiveViolatedDirective.directiveList(), blockedURL, consoleMessage, String(), TextPosition(OrdinalNumber::beforeFirst(), OrdinalNumber::beforeFirst()), state);727 // FIXME: Extract source file, content, and position from JSC::ExecState. 728 return reportViolation(violatedDirective, effectiveViolatedDirective.nameForReporting().convertToASCIILowercase(), effectiveViolatedDirective.directiveList(), blockedURL, consoleMessage, String(), StringView(), TextPosition(OrdinalNumber::beforeFirst(), OrdinalNumber::beforeFirst()), state); 729 729 } 730 730 731 731 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const String& blockedURL, const String& consoleMessage, JSC::JSGlobalObject* state) const 732 732 { 733 // FIXME: Extract source file and sourceposition from JSC::ExecState.734 return reportViolation(effectiveViolatedDirective, violatedDirective, violatedDirectiveList, blockedURL, consoleMessage, String(), TextPosition(OrdinalNumber::beforeFirst(), OrdinalNumber::beforeFirst()), state);735 } 736 737 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const String& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, const URL& preRedirectURL, JSC::JSGlobalObject* state, Element* element) const738 { 739 return reportViolation(effectiveViolatedDirective, violatedDirective.nameForReporting().convertToASCIILowercase(), violatedDirective.directiveList(), blockedURL, consoleMessage, sourceURL, source Position, state, preRedirectURL, element);740 } 741 742 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const String& blockedURLString, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject* state, const URL& preRedirectURL, Element* element) const733 // FIXME: Extract source file, content, and position from JSC::ExecState. 734 return reportViolation(effectiveViolatedDirective, violatedDirective, violatedDirectiveList, blockedURL, consoleMessage, String(), StringView(), TextPosition(OrdinalNumber::beforeFirst(), OrdinalNumber::beforeFirst()), state); 735 } 736 737 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const String& blockedURL, const String& consoleMessage, const String& sourceURL, const StringView& sourceContent, const TextPosition& sourcePosition, const URL& preRedirectURL, JSC::JSGlobalObject* state, Element* element) const 738 { 739 return reportViolation(effectiveViolatedDirective, violatedDirective.nameForReporting().convertToASCIILowercase(), violatedDirective.directiveList(), blockedURL, consoleMessage, sourceURL, sourceContent, sourcePosition, state, preRedirectURL, element); 740 } 741 742 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const String& blockedURLString, const String& consoleMessage, const String& sourceURL, const StringView& sourceContent, const TextPosition& sourcePosition, JSC::JSGlobalObject* state, const URL& preRedirectURL, Element* element) const 743 743 { 744 744 logToConsole(consoleMessage, sourceURL, sourcePosition.m_line, sourcePosition.m_column, state); … … 754 754 info.lineNumber = sourcePosition.m_line.oneBasedInt(); 755 755 info.columnNumber = sourcePosition.m_column.oneBasedInt(); 756 info.sample = violatedDirectiveList.shouldReportSample(violatedDirective) ? sourceContent.left(40).toString() : emptyString(); 756 757 757 758 if (m_client) … … 802 803 violationEventInit.lineNumber = info.lineNumber; 803 804 violationEventInit.columnNumber = info.columnNumber; 805 violationEventInit.sample = info.sample; 804 806 violationEventInit.bubbles = true; 805 807 if (m_client) -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h
r286136 r286150 224 224 void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const String& blockedURL, const String& consoleMessage, JSC::JSGlobalObject*) const; 225 225 void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList&, const String& blockedURL, const String& consoleMessage, JSC::JSGlobalObject* = nullptr) const; 226 void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const String& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, const URL& preRedirectURL = URL(), JSC::JSGlobalObject* = nullptr, Element* = nullptr) const;227 void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const String& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject*, const URL& preRedirectURL = URL(), Element* = nullptr) const;226 void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const String& blockedURL, const String& consoleMessage, const String& sourceURL, const StringView& sourceContent, const TextPosition& sourcePosition, const URL& preRedirectURL = URL(), JSC::JSGlobalObject* = nullptr, Element* = nullptr) const; 227 void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const String& blockedURL, const String& consoleMessage, const String& sourceURL, const StringView& sourceContent, const TextPosition& sourcePosition, JSC::JSGlobalObject*, const URL& preRedirectURL = URL(), Element* = nullptr) const; 228 228 void reportBlockedScriptExecutionToInspector(const String& directiveText) const; 229 229 -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyClient.h
r284080 r286150 37 37 String documentURI; 38 38 String sourceFile; 39 String sample; 39 40 int lineNumber { 0 }; 40 41 int columnNumber { 0 }; -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp
r284959 r286150 643 643 } 644 644 645 bool ContentSecurityPolicyDirectiveList::shouldReportSample(const String& violatedDirective) const 646 { 647 ContentSecurityPolicySourceListDirective* directive = nullptr; 648 if (violatedDirective.startsWith(ContentSecurityPolicyDirectiveNames::styleSrc)) 649 directive = m_styleSrc.get(); 650 else if (violatedDirective.startsWith(ContentSecurityPolicyDirectiveNames::scriptSrc)) 651 directive = m_scriptSrc.get(); 652 653 return directive && directive->shouldReportSample(); 654 } 655 645 656 } // namespace WebCore -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h
r284959 r286150 87 87 const String& webAssemblyDisabledErrorMessage() const { return m_webAssemblyDisabledErrorMessage; } 88 88 bool isReportOnly() const { return m_reportOnly; } 89 bool shouldReportSample(const String&) const; 89 90 const Vector<String>& reportURIs() const { return m_reportURIs; } 90 91 -
trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp
r284959 r286150 249 249 } 250 250 251 if (skipExactlyIgnoringASCIICase(buffer, "'report-sample'")) { 252 m_reportSample = true; 253 return source; 254 } 255 251 256 auto begin = buffer.position(); 252 257 auto beginHost = begin; -
trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.h
r284959 r286150 56 56 bool allowNonParserInsertedScripts() const { return m_allowNonParserInsertedScripts; } 57 57 bool allowUnsafeHashes() const { return m_allowUnsafeHashes; } 58 bool shouldReportSample() const { return m_reportSample; } 58 59 59 60 private: … … 97 98 bool m_allowNonParserInsertedScripts { false }; 98 99 bool m_allowUnsafeHashes { false }; 100 bool m_reportSample { false }; 99 101 }; 100 102 -
trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceListDirective.h
r284959 r286150 46 46 bool allowEval() const { return m_sourceList.allowEval(); } 47 47 bool allowNonParserInsertedScripts() const { return m_sourceList.allowNonParserInsertedScripts(); } 48 bool shouldReportSample() const { return m_sourceList.shouldReportSample(); } 48 49 49 50 OptionSet<ContentSecurityPolicyHashAlgorithm> hashAlgorithmsUsed() const { return m_sourceList.hashAlgorithmsUsed(); }
Note: See TracChangeset
for help on using the changeset viewer.