WebKit Bugzilla
Attachment 357767 Details for
Bug 192906
: Add diagnostic logging for safe browsing provider and action
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192906-20181219175141.patch (text/plain), 16.69 KB, created by
Alex Christensen
on 2018-12-19 17:51:41 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2018-12-19 17:51:41 PST
Size:
16.69 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 239408) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,16 @@ >+2018-12-19 Alex Christensen <achristensen@webkit.org> >+ >+ Add diagnostic logging for safe browsing provider and action >+ https://bugs.webkit.org/show_bug.cgi?id=192906 >+ <rdar://problem/46287888> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * page/DiagnosticLoggingKeys.cpp: >+ (WebCore::DiagnosticLoggingKeys::safeBrowsingAction): >+ (WebCore::DiagnosticLoggingKeys::safeBrowsingProvider): >+ * page/DiagnosticLoggingKeys.h: >+ > 2018-12-18 Ryosuke Niwa <rniwa@webkit.org> > > SVGUseElement::findTarget should return nullptr when there is a cycle >Index: Source/WebCore/page/DiagnosticLoggingKeys.cpp >=================================================================== >--- Source/WebCore/page/DiagnosticLoggingKeys.cpp (revision 239408) >+++ Source/WebCore/page/DiagnosticLoggingKeys.cpp (working copy) >@@ -520,6 +520,16 @@ String DiagnosticLoggingKeys::reloadReva > return "reloadRevalidatingExpired"_s; > } > >+String DiagnosticLoggingKeys::safeBrowsingAction() >+{ >+ return "safeBrowsingAction"_s; >+} >+ >+String DiagnosticLoggingKeys::safeBrowsingProvider() >+{ >+ return "safeBrowsingProvider"_s; >+} >+ > String DiagnosticLoggingKeys::sameLoadKey() > { > return "sameLoad"_s; >Index: Source/WebCore/page/DiagnosticLoggingKeys.h >=================================================================== >--- Source/WebCore/page/DiagnosticLoggingKeys.h (revision 239408) >+++ Source/WebCore/page/DiagnosticLoggingKeys.h (working copy) >@@ -146,6 +146,8 @@ public: > WEBCORE_EXPORT static String retrievalKey(); > WEBCORE_EXPORT static String retrievalRequestKey(); > WEBCORE_EXPORT static String revalidatingKey(); >+ WEBCORE_EXPORT static String safeBrowsingAction(); >+ WEBCORE_EXPORT static String safeBrowsingProvider(); > static String sameLoadKey(); > static String scriptKey(); > static String serviceWorkerKey(); >Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 239418) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,27 @@ >+2018-12-19 Alex Christensen <achristensen@webkit.org> >+ >+ Add diagnostic logging for safe browsing provider and action >+ https://bugs.webkit.org/show_bug.cgi?id=192906 >+ <rdar://problem/46287888> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _showSafeBrowsingWarning:completionHandler:]): >+ (-[WKWebView _showSafeBrowsingWarningWithTitle:warning:details:completionHandler:]): >+ (-[WKWebView _showSafeBrowsingWarningWithURL:providerDiagnosticID:title:warning:details:completionHandler:]): >+ (-[WKWebView _showSafeBrowsingWarningWithURL:title:warning:details:completionHandler:]): Deleted. >+ * UIProcess/API/Cocoa/WKWebViewPrivate.h: >+ * UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm: >+ (WebKit::providerDiagnosticIdentifier): >+ (WebKit::SafeBrowsingWarning::SafeBrowsingWarning): >+ (WebKit::SafeBrowsingWarning::actionDiagnosticID): >+ * UIProcess/Cocoa/WebViewImpl.mm: >+ (WebKit::WebViewImpl::showSafeBrowsingWarning): >+ * UIProcess/SafeBrowsingWarning.h: >+ (WebKit::SafeBrowsingWarning::create): >+ (WebKit::SafeBrowsingWarning::providerDiagnosticID const): >+ > 2018-12-19 Tim Horton <timothy_horton@apple.com> > > Use delegate instead of drawingDelegate in WKDrawingView >Index: Source/WebKit/UIProcess/SafeBrowsingWarning.h >=================================================================== >--- Source/WebKit/UIProcess/SafeBrowsingWarning.h (revision 239408) >+++ Source/WebKit/UIProcess/SafeBrowsingWarning.h (working copy) >@@ -36,6 +36,8 @@ OBJC_CLASS SSBServiceLookupResult; > > namespace WebKit { > >+enum class ContinueUnsafeLoad : bool; >+ > class SafeBrowsingWarning : public RefCounted<SafeBrowsingWarning> { > public: > #if HAVE(SAFE_BROWSING) >@@ -45,9 +47,9 @@ public: > } > #endif > #if PLATFORM(COCOA) >- static Ref<SafeBrowsingWarning> create(URL&& url, String&& title, String&& warning, RetainPtr<NSAttributedString>&& details) >+ static Ref<SafeBrowsingWarning> create(URL&& url, String&& title, String&& warning, std::optional<uint32_t>&& providerDiagnosticID, RetainPtr<NSAttributedString>&& details) > { >- return adoptRef(*new SafeBrowsingWarning(WTFMove(url), WTFMove(title), WTFMove(warning), WTFMove(details))); >+ return adoptRef(*new SafeBrowsingWarning(WTFMove(url), WTFMove(title), WTFMove(warning), WTFMove(providerDiagnosticID), WTFMove(details))); > } > #endif > >@@ -55,9 +57,11 @@ public: > const String& title() const { return m_title; } > const String& warning() const { return m_warning; } > bool forMainFrameNavigation() const { return m_forMainFrameNavigation; } >+ std::optional<uint32_t> providerDiagnosticID() const { return m_providerDiagnosticID; } > #if PLATFORM(COCOA) > RetainPtr<NSAttributedString> details() const { return m_details; } > #endif >+ static std::optional<uint32_t> actionDiagnosticID(const Variant<ContinueUnsafeLoad, URL>&); > > static NSURL *visitUnsafeWebsiteSentinel(); > static NSURL *confirmMalwareSentinel(); >@@ -67,13 +71,14 @@ private: > SafeBrowsingWarning(const URL&, bool, SSBServiceLookupResult *); > #endif > #if PLATFORM(COCOA) >- SafeBrowsingWarning(URL&&, String&&, String&&, RetainPtr<NSAttributedString>&&); >+ SafeBrowsingWarning(URL&&, String&&, String&&, std::optional<uint32_t>&&, RetainPtr<NSAttributedString>&&); > #endif > > URL m_url; > String m_title; > String m_warning; > bool m_forMainFrameNavigation { false }; >+ std::optional<uint32_t> m_providerDiagnosticID; > #if PLATFORM(COCOA) > RetainPtr<NSAttributedString> m_details; > #endif >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (revision 239408) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (working copy) >@@ -98,6 +98,7 @@ > #import "_WKSessionStateInternal.h" > #import "_WKVisitedLinkStoreInternal.h" > #import "_WKWebsitePoliciesInternal.h" >+#import <WebCore/DiagnosticLoggingKeys.h> > #import <WebCore/GraphicsContextCG.h> > #import <WebCore/IOSurface.h> > #import <WebCore/JSDOMBinding.h> >@@ -1278,11 +1279,18 @@ - (void)_didChangeEditorState > > - (void)_showSafeBrowsingWarning:(const WebKit::SafeBrowsingWarning&)warning completionHandler:(CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)>&&)completionHandler > { >+ if (auto identifier = warning.providerDiagnosticID()) >+ _page->logDiagnosticMessageWithResult(WebCore::DiagnosticLoggingKeys::safeBrowsingProvider(), emptyString(), *identifier, WebCore::ShouldSample::No); >+ > _safeBrowsingWarning = adoptNS([[WKSafeBrowsingWarning alloc] initWithFrame:self.bounds safeBrowsingWarning:warning completionHandler:[weakSelf = WeakObjCPtr<WKWebView>(self), completionHandler = WTFMove(completionHandler)] (auto&& result) mutable { > completionHandler(WTFMove(result)); > auto strongSelf = weakSelf.get(); > if (!strongSelf) > return; >+ >+ if (auto action = WebKit::SafeBrowsingWarning::actionDiagnosticID(result)) >+ strongSelf->_page->logDiagnosticMessageWithResult(WebCore::DiagnosticLoggingKeys::safeBrowsingAction(), emptyString(), *action, WebCore::ShouldSample::No); >+ > bool navigatesMainFrame = WTF::switchOn(result, > [] (WebKit::ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == WebKit::ContinueUnsafeLoad::Yes; }, > [] (const URL&) { return true; } >@@ -4815,12 +4823,12 @@ + (BOOL)_handlesSafeBrowsing > - (void)_showSafeBrowsingWarningWithTitle:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler > { > // FIXME: Adopt _showSafeBrowsingWarningWithURL and remove this function. >- [self _showSafeBrowsingWarningWithURL:nil title:title warning:warning details:details completionHandler:completionHandler]; >+ [self _showSafeBrowsingWarningWithURL:nil providerDiagnosticID:0 title:title warning:warning details:details completionHandler:completionHandler]; > } > >-- (void)_showSafeBrowsingWarningWithURL:(NSURL *)url title:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler >+- (void)_showSafeBrowsingWarningWithURL:(NSURL *)url providerDiagnosticID:(uint32_t)identifier title:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler > { >- auto safeBrowsingWarning = WebKit::SafeBrowsingWarning::create(url, title, warning, details); >+ auto safeBrowsingWarning = WebKit::SafeBrowsingWarning::create(url, title, warning, identifier ? std::optional<uint32_t>(identifier) : std::nullopt, details); > auto wrapper = [completionHandler = makeBlockPtr(completionHandler)] (Variant<WebKit::ContinueUnsafeLoad, URL>&& variant) { > switchOn(variant, [&] (WebKit::ContinueUnsafeLoad continueUnsafeLoad) { > switch (continueUnsafeLoad) { >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (revision 239408) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (working copy) >@@ -194,7 +194,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEd > + (NSURL *)_confirmMalwareSentinel WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > + (NSURL *)_visitUnsafeWebsiteSentinel WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (void)_showSafeBrowsingWarningWithTitle:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >-- (void)_showSafeBrowsingWarningWithURL:(NSURL *)url title:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+- (void)_showSafeBrowsingWarningWithURL:(NSURL *)url providerDiagnosticID:(uint32_t)identifier title:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > - (void)_isJITEnabled:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (void)_removeDataDetectedLinks:(dispatch_block_t)completion WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >Index: Source/WebKit/UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm >=================================================================== >--- Source/WebKit/UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm (revision 239408) >+++ Source/WebKit/UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm (working copy) >@@ -26,6 +26,7 @@ > #import "config.h" > #import "SafeBrowsingWarning.h" > >+#import "PageClient.h" > #import "SafeBrowsingSPI.h" > #import <WebCore/LocalizedStrings.h> > #import <pal/spi/cocoa/NSAttributedStringSPI.h> >@@ -65,6 +66,15 @@ static String localizedProvider(SSBServi > return WEB_UI_NSSTRING(@"Google Safe Browsing", "Google Safe Browsing"); > } > >+static std::optional<uint32_t> providerDiagnosticIdentifier(SSBServiceLookupResult *result) >+{ >+ if ([result.provider isEqualToString:SSBProviderTencent]) >+ return 1; >+ if ([result.provider isEqualToString:SSBProviderGoogle]) >+ return 0; >+ return std::nullopt; >+} >+ > > static void replace(NSMutableAttributedString *string, NSString *toReplace, NSString *replaceWith) > { >@@ -154,15 +164,17 @@ SafeBrowsingWarning::SafeBrowsingWarning > , m_title(safeBrowsingTitleText(result)) > , m_warning(safeBrowsingWarningText(result)) > , m_forMainFrameNavigation(forMainFrameNavigation) >+ , m_providerDiagnosticID(providerDiagnosticIdentifier(result)) > , m_details(safeBrowsingDetailsText(url, result)) > { > } > #endif > >-SafeBrowsingWarning::SafeBrowsingWarning(URL&& url, String&& title, String&& warning, RetainPtr<NSAttributedString>&& details) >+SafeBrowsingWarning::SafeBrowsingWarning(URL&& url, String&& title, String&& warning, std::optional<uint32_t>&& providerID, RetainPtr<NSAttributedString>&& details) > : m_url(WTFMove(url)) > , m_title(WTFMove(title)) > , m_warning(WTFMove(warning)) >+ , m_providerDiagnosticID(WTFMove(providerID)) > , m_details(WTFMove(details)) > { > } >@@ -177,4 +189,20 @@ NSURL *SafeBrowsingWarning::confirmMalwa > return [NSURL URLWithString:@"WKConfirmMalwareSentinel"]; > } > >+std::optional<uint32_t> SafeBrowsingWarning::actionDiagnosticID(const Variant<ContinueUnsafeLoad, URL>& result) >+{ >+ return WTF::switchOn(result, >+ [] (ContinueUnsafeLoad continueUnsafeLoad) -> std::optional<uint32_t> { >+ switch (continueUnsafeLoad) { >+ case ContinueUnsafeLoad::Yes: >+ return 0; >+ case ContinueUnsafeLoad::No: >+ return 1; >+ } >+ }, [] (const URL&) { >+ return std::nullopt; >+ } >+ ); >+} >+ > } >Index: Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >=================================================================== >--- Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (revision 239408) >+++ Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (working copy) >@@ -48,6 +48,7 @@ > #import "RemoteLayerTreeDrawingAreaProxy.h" > #import "RemoteObjectRegistry.h" > #import "RemoteObjectRegistryMessages.h" >+#import "SafeBrowsingWarning.h" > #import "StringUtilities.h" > #import "TextChecker.h" > #import "TextCheckerState.h" >@@ -79,6 +80,7 @@ > #import <WebCore/AXObjectCache.h> > #import <WebCore/ActivityState.h> > #import <WebCore/ColorMac.h> >+#import <WebCore/DiagnosticLoggingKeys.h> > #import <WebCore/DictionaryLookup.h> > #import <WebCore/DragData.h> > #import <WebCore/DragItem.h> >@@ -1621,10 +1623,17 @@ void WebViewImpl::showSafeBrowsingWarnin > if (!m_view) > return completionHandler(ContinueUnsafeLoad::Yes); > >+ if (auto identifier = warning.providerDiagnosticID()) >+ m_page->logDiagnosticMessageWithResult(WebCore::DiagnosticLoggingKeys::safeBrowsingProvider(), emptyString(), *identifier, WebCore::ShouldSample::No); >+ > m_safeBrowsingWarning = adoptNS([[WKSafeBrowsingWarning alloc] initWithFrame:[m_view bounds] safeBrowsingWarning:warning completionHandler:[weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)] (auto&& result) mutable { > completionHandler(WTFMove(result)); > if (!weakThis) > return; >+ >+ if (auto action = SafeBrowsingWarning::actionDiagnosticID(result)) >+ weakThis->m_page->logDiagnosticMessageWithResult(WebCore::DiagnosticLoggingKeys::safeBrowsingAction(), emptyString(), *action, WebCore::ShouldSample::No); >+ > bool navigatesMainFrame = WTF::switchOn(result, > [] (ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == ContinueUnsafeLoad::Yes; }, > [] (const URL&) { return true; } >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 239418) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,14 @@ >+2018-12-19 Alex Christensen <achristensen@webkit.org> >+ >+ Add diagnostic logging for safe browsing provider and action >+ https://bugs.webkit.org/show_bug.cgi?id=192906 >+ <rdar://problem/46287888> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm: >+ (TEST): >+ > 2018-12-19 Benjamin Poulain <benjamin@webkit.org> > > <rdar://problem/46194315> macOS: WebKit1 does not handle occlusion changes >Index: Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm >=================================================================== >--- Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (revision 239408) >+++ Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (working copy) >@@ -260,7 +260,7 @@ TEST(SafeBrowsing, ShowWarningSPI) > auto webView = adoptNS([WKWebView new]); > auto showWarning = ^{ > completionHandlerCalled = false; >- [webView _showSafeBrowsingWarningWithURL:nil title:@"test title" warning:@"test warning" details:[[[NSAttributedString alloc] initWithString:@"test details"] autorelease] completionHandler:^(BOOL shouldContinue) { >+ [webView _showSafeBrowsingWarningWithURL:nil providerDiagnosticID:42 title:@"test title" warning:@"test warning" details:[[[NSAttributedString alloc] initWithString:@"test details"] autorelease] completionHandler:^(BOOL shouldContinue) { > shouldContinueValue = shouldContinue; > completionHandlerCalled = true; > }];
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
achristensen
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192906
: 357767