[webkit-changes] [WebKit/WebKit] 2e2acc: [Reporting API] Refactor network send logic to Rep...

Brent Fulgham noreply at github.com
Tue Sep 6 17:47:23 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2e2acc4000997cddc8be168ae8f79fc4517b3c79
      https://github.com/WebKit/WebKit/commit/2e2acc4000997cddc8be168ae8f79fc4517b3c79
  Author: Brent Fulgham <bfulgham at apple.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Modules/reporting/ReportBody.cpp
    M Source/WebCore/Modules/reporting/ReportBody.h
    M Source/WebCore/Modules/reporting/ReportingClient.h
    M Source/WebCore/Modules/reporting/TestReportBody.cpp
    M Source/WebCore/Modules/reporting/TestReportBody.h
    A Source/WebCore/Modules/reporting/ViolationReportType.h
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/bindings/js/JSReportBodyCustom.cpp
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/loader/DocumentLoader.cpp
    M Source/WebCore/loader/DocumentLoader.h
    M Source/WebCore/loader/PingLoader.cpp
    M Source/WebCore/loader/PingLoader.h
    M Source/WebCore/page/csp/CSPViolationReportBody.cpp
    M Source/WebCore/page/csp/CSPViolationReportBody.h
    M Source/WebCore/page/csp/ContentSecurityPolicy.cpp
    M Source/WebCore/page/csp/ContentSecurityPolicyClient.h
    M Source/WebCore/workers/WorkerGlobalScope.cpp
    M Source/WebCore/workers/WorkerGlobalScope.h
    M Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
    M Source/WebKit/NetworkProcess/NetworkResourceLoader.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  [Reporting API] Refactor network send logic to Report-related code
https://bugs.webkit.org/show_bug.cgi?id=244855
<rdar://problem/99618219>

Reviewed by Chris Dumez.

Bits of logic about how to distribute reports to endpoints is spread around the ContentSecurityObject, PingLoader, (COEP/COOP reporting before it was reverted), and now the Reporting module. This patch consolidates the behavior in the Reporting code where it can be used for all report types.

1. Rather than use a new 'ReportBodyType' type, it uses the existing 'ViolationReportType', since ReportBodies are 1:1 associated with ViolationReport types.
2. Remove the single-purpose 'sendCSPViolationReport' method and replace with a more generic 'sendReportToEndpoints'.
3. Modify the ReportingClient to present a signature for sending reports.
4. Modify the ContentSecurityPolicy code to use the new 'sendReportToEndpoints' client method.
5. Modify Document and NetworkLoader to implement a 'sendReportToEndpoints' method.
6. Add a stub implementation to WorkerGlobalScope to send reports. This will be done in a separate change.

* Source/WebCore/Headers.cmake: Add new ViolationReportType.h header.
* Source/WebCore/Modules/reporting/ReportBody.cpp:
(WebCore::ReportBody::ReportBody): Switch from ReportBodyType to ViolationReportType.
(WebCore::ReportBody::reportBodyType const): Ditto.
* Source/WebCore/Modules/reporting/ReportBody.h:
* Source/WebCore/Modules/reporting/ReportingClient.h: Add new 'sendReportToEndpoints' method.
* Source/WebCore/Modules/reporting/TestReportBody.cpp:
(WebCore::TestReportBody::TestReportBody): Switch from ReportBodyType to ViolationReportType.
* Source/WebCore/Modules/reporting/TestReportBody.h:
(isType): Switch from ReportBodyType to ViolationReportType.
* Source/WebCore/Modules/reporting/ViolationReportType.h: Copied from Source/WebCore/Modules/reporting/ReportBody.h.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: Add new ViolationReportType.h header.
* Source/WebCore/bindings/js/JSReportBodyCustom.cpp: Ditto.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::sendReportToEndpoints): Added.
* Source/WebCore/dom/Document.h:
* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::sendCSPViolationReport): Deleted.
* Source/WebCore/loader/PingLoader.cpp:
(WebCore::PingLoader::sendViolationReport): Recognize the 'Test' ViolationReportType.
(WebCore::PingLoader::startPingLoad): Ditto.
* Source/WebCore/loader/PingLoader.h:
* Source/WebCore/page/csp/CSPViolationReportBody.cpp:
(WebCore::CSPViolationReportBody::CSPViolationReportBody): Switch from ReportBodyType to ViolationReportType.
* Source/WebCore/page/csp/CSPViolationReportBody.h:
(isType): Ditto.
* Source/WebCore/page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::reportViolation const): Update to use the new ReportingClient mechanism
to send violation reports (rather than special casing for NetworkLoader and Document explicitly).
* Source/WebCore/workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::sendReportToEndpoints): Added stub (for future work).
* Source/WebCore/workers/WorkerGlobalScope.h:
* Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::sendCSPViolationReport): Replaced with 'sendReportToEndpoints'.
(WebKit::NetworkResourceLoader::sendReportToEndpoints): Added new implementation to support the ReportingClient API.
* Source/WebKit/NetworkProcess/NetworkResourceLoader.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<RefPtr<WebCore::ReportBody>>::encode): Switch from ReportBodyType to ViolationReportType.
(IPC::ArgumentCoder<RefPtr<WebCore::ReportBody>>::decode): Ditto.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendCSPViolationReport): Deleted.
(WebKit::WebPage::sendReportToEndpoints): Added.
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

Canonical link: https://commits.webkit.org/254208@main




More information about the webkit-changes mailing list