Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[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
- Loading branch information
1 parent
dc19877
commit 2e2acc4000997cddc8be168ae8f79fc4517b3c79
Showing
27 changed files
with
141 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2022 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace WebCore { | ||
|
||
enum class ViolationReportType : uint8_t { | ||
ContentSecurityPolicy, | ||
StandardReportingAPIViolation, // https://www.w3.org/TR/reporting/#try-delivery | ||
Test, // https://www.w3.org/TR/reporting-1/#generate-test-report-command | ||
// More to come | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
namespace WTF { | ||
|
||
template<> struct EnumTraits<WebCore::ViolationReportType> { | ||
using values = EnumValues< | ||
WebCore::ViolationReportType, | ||
WebCore::ViolationReportType::ContentSecurityPolicy, | ||
WebCore::ViolationReportType::StandardReportingAPIViolation, | ||
WebCore::ViolationReportType::Test | ||
>; | ||
}; | ||
|
||
} // namespace WTF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.