Title: [271294] trunk/Source/WebKit
Revision
271294
Author
[email protected]
Date
2021-01-08 07:22:28 -0800 (Fri, 08 Jan 2021)

Log Message

Service Worker is no longer inspectable
https://bugs.webkit.org/show_bug.cgi?id=220406
<rdar://problem/72883757>

Reviewed by Per Arne Vollan.

We were sending the sandbox extension later when enabling remote inspector.
But this is not soon enough for inspecting service workers.
For that reason, send the sandbox extension at process init time based on whether develop menu is on or not.

Manually tested by validating that Develop Menu can list running service workers.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::shouldEnableRemoteInspector):
(WebKit::WebProcessProxy::enableRemoteInspectorIfNeeded):
* UIProcess/WebProcessProxy.h:
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
(WebKit::WebProcess::enableRemoteWebInspector):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (271293 => 271294)


--- trunk/Source/WebKit/ChangeLog	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/ChangeLog	2021-01-08 15:22:28 UTC (rev 271294)
@@ -1,3 +1,33 @@
+2021-01-08  Youenn Fablet  <[email protected]>
+
+        Service Worker is no longer inspectable
+        https://bugs.webkit.org/show_bug.cgi?id=220406
+        <rdar://problem/72883757>
+
+        Reviewed by Per Arne Vollan.
+
+        We were sending the sandbox extension later when enabling remote inspector.
+        But this is not soon enough for inspecting service workers.
+        For that reason, send the sandbox extension at process init time based on whether develop menu is on or not.
+
+        Manually tested by validating that Develop Menu can list running service workers.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
+        (WebKit::WebProcessProxy::shouldEnableRemoteInspector):
+        (WebKit::WebProcessProxy::enableRemoteInspectorIfNeeded):
+        * UIProcess/WebProcessProxy.h:
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        (WebKit::WebProcess::enableRemoteWebInspector):
+
 2021-01-08  Chris Lord  <[email protected]>
 
         [WPE] Enable smooth-motion and kinetic scrolling on touchpads

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (271293 => 271294)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-01-08 15:22:28 UTC (rev 271294)
@@ -56,6 +56,9 @@
     encoder << containerCachesDirectoryExtensionHandle;
     encoder << containerTemporaryDirectoryExtensionHandle;
 #endif
+#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
+    encoder << enableRemoteWebInspectorExtensionHandle;
+#endif
     encoder << webCoreLoggingChannels;
     encoder << webKitLoggingChannels;
 #if ENABLE(MEDIA_STREAM)
@@ -236,6 +239,14 @@
     parameters.containerTemporaryDirectoryExtensionHandle = WTFMove(*containerTemporaryDirectoryExtensionHandle);
 
 #endif
+#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
+    Optional<SandboxExtension::Handle> enableRemoteWebInspectorExtensionHandle;
+    decoder >> enableRemoteWebInspectorExtensionHandle;
+    if (!enableRemoteWebInspectorExtensionHandle)
+        return false;
+    parameters.enableRemoteWebInspectorExtensionHandle = WTFMove(*enableRemoteWebInspectorExtensionHandle);
+#endif
+
     if (!decoder.decode(parameters.webCoreLoggingChannels))
         return false;
     if (!decoder.decode(parameters.webKitLoggingChannels))

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (271293 => 271294)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-01-08 15:22:28 UTC (rev 271294)
@@ -82,6 +82,9 @@
     SandboxExtension::Handle containerCachesDirectoryExtensionHandle;
     SandboxExtension::Handle containerTemporaryDirectoryExtensionHandle;
 #endif
+#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
+    SandboxExtension::Handle enableRemoteWebInspectorExtensionHandle;
+#endif
 #if ENABLE(MEDIA_STREAM)
     SandboxExtension::Handle audioCaptureExtensionHandle;
 #endif

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (271293 => 271294)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-01-08 15:22:28 UTC (rev 271294)
@@ -332,6 +332,13 @@
     if (!m_resolvedPaths.containerTemporaryDirectory.isEmpty())
         SandboxExtension::createHandleWithoutResolvingPath(m_resolvedPaths.containerTemporaryDirectory, SandboxExtension::Type::ReadWrite, parameters.containerTemporaryDirectoryExtensionHandle);
 #endif
+#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
+    if (WebProcessProxy::shouldEnableRemoteInspector()) {
+        SandboxExtension::Handle enableRemoteWebInspectorExtensionHandle;
+        if (SandboxExtension::createHandleForMachLookup("com.apple.webinspector"_s, WTF::nullopt, enableRemoteWebInspectorExtensionHandle))
+            parameters.enableRemoteWebInspectorExtensionHandle = WTFMove(enableRemoteWebInspectorExtensionHandle);
+    }
+#endif
 
     parameters.fontAllowList = m_fontAllowList;
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm (271293 => 271294)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2021-01-08 15:22:28 UTC (rev 271294)
@@ -209,20 +209,21 @@
 #endif
 
 #if ENABLE(REMOTE_INSPECTOR)
-void WebProcessProxy::enableRemoteInspectorIfNeeded()
+bool WebProcessProxy::shouldEnableRemoteInspector()
 {
 #if PLATFORM(IOS_FAMILY)
-    if (!CFPreferencesGetAppIntegerValue(WIRRemoteInspectorEnabledKey, WIRRemoteInspectorDomainName, nullptr))
-        return;
+    return CFPreferencesGetAppIntegerValue(WIRRemoteInspectorEnabledKey, WIRRemoteInspectorDomainName, nullptr);
 #else
-    if (!CFPreferencesGetAppIntegerValue(CFSTR("ShowDevelopMenu"), CFSTR("com.apple.Safari.SandboxBroker"), nullptr))
-        return;
+    return CFPreferencesGetAppIntegerValue(CFSTR("ShowDevelopMenu"), CFSTR("com.apple.Safari.SandboxBroker"), nullptr);
 #endif
-    SandboxExtension::Handle handle;
-    auto auditToken = connection() ? connection()->getAuditToken() : WTF::nullopt;
-    if (SandboxExtension::createHandleForMachLookup("com.apple.webinspector"_s, auditToken, handle))
-        send(Messages::WebProcess::EnableRemoteWebInspector(handle), 0);
 }
+
+void WebProcessProxy::enableRemoteInspectorIfNeeded()
+{
+    if (!shouldEnableRemoteInspector())
+        return;
+    send(Messages::WebProcess::EnableRemoteWebInspector(), 0);
+}
 #endif
 
 void WebProcessProxy::unblockAccessibilityServerIfNeeded()

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (271293 => 271294)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2021-01-08 15:22:28 UTC (rev 271294)
@@ -407,6 +407,10 @@
     void pageMutedStateChanged(WebCore::PageIdentifier, WebCore::MediaProducer::MutedStateFlags);
     void pageIsBecomingInvisible(WebCore::PageIdentifier);
 
+#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
+    static bool shouldEnableRemoteInspector();
+#endif
+
 protected:
     WebProcessProxy(WebProcessPool&, WebsiteDataStore*, IsPrewarmed);
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (271293 => 271294)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2021-01-08 15:22:28 UTC (rev 271294)
@@ -318,7 +318,7 @@
 #if PLATFORM(COCOA)
     void setMediaMIMETypes(const Vector<String>);
 #if ENABLE(REMOTE_INSPECTOR)
-    void enableRemoteWebInspector(const SandboxExtension::Handle&);
+    void enableRemoteWebInspector();
 #endif
     void unblockServicesRequiredByAccessibility(const SandboxExtension::HandleArray&);
 #if ENABLE(CFPREFS_DIRECT_MODE)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (271293 => 271294)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2021-01-08 15:22:28 UTC (rev 271294)
@@ -133,7 +133,7 @@
 #if PLATFORM(COCOA)
     SetMediaMIMETypes(Vector<String> types)
 #if ENABLE(REMOTE_INSPECTOR)
-    EnableRemoteWebInspector(WebKit::SandboxExtension::Handle handle);
+    EnableRemoteWebInspector();
 #endif
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (271293 => 271294)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-01-08 13:29:01 UTC (rev 271293)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-01-08 15:22:28 UTC (rev 271294)
@@ -260,7 +260,11 @@
     SandboxExtension::consumePermanently(parameters.containerCachesDirectoryExtensionHandle);
     SandboxExtension::consumePermanently(parameters.containerTemporaryDirectoryExtensionHandle);
 #endif
+#if PLATFORM(COCOA) && ENABLE(REMOTE_INSPECTOR)
+    if (SandboxExtension::consumePermanently(parameters.enableRemoteWebInspectorExtensionHandle))
+        Inspector::RemoteInspector::setNeedMachSandboxExtension(false);
 #endif
+#endif
 
     // Disable NSURLCache.
     auto urlCache = adoptNS([[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]);
@@ -991,10 +995,8 @@
 #endif
 
 #if ENABLE(REMOTE_INSPECTOR)
-void WebProcess::enableRemoteWebInspector(const SandboxExtension::Handle& handle)
+void WebProcess::enableRemoteWebInspector()
 {
-    SandboxExtension::consumePermanently(handle);
-    Inspector::RemoteInspector::setNeedMachSandboxExtension(false);
     Inspector::RemoteInspector::singleton();
 }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to