From 3d350e36010b2ac7b77f9d7c047c9e5008ace595 Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Mon, 25 Nov 2024 22:12:20 +0600 Subject: [PATCH 1/4] set BSK rev --- DuckDuckGo.xcodeproj/project.pbxproj | 8 ++++---- .../xcshareddata/swiftpm/Package.resolved | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index ed5f648507..8a641aa491 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -365,9 +365,9 @@ 6FEC0B852C999352006B4F6E /* FavoriteItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FEC0B842C999352006B4F6E /* FavoriteItem.swift */; }; 6FEC0B882C999961006B4F6E /* FavoritesListInteractingAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FEC0B872C999961006B4F6E /* FavoritesListInteractingAdapter.swift */; }; 6FF915822B88E07A0042AC87 /* AdAttributionFetcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF915802B88E0750042AC87 /* AdAttributionFetcherTests.swift */; }; - 6FF9AD452CE766F700C5A406 /* NewTabPageControllerPixelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF9AD442CE766F700C5A406 /* NewTabPageControllerPixelTests.swift */; }; 6FF9AD3F2CE63DD800C5A406 /* TabSwitcherOpenDailyPixel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF9AD3E2CE63DC200C5A406 /* TabSwitcherOpenDailyPixel.swift */; }; 6FF9AD412CE6610F00C5A406 /* TabSwitcherDailyPixelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF9AD402CE6610600C5A406 /* TabSwitcherDailyPixelTests.swift */; }; + 6FF9AD452CE766F700C5A406 /* NewTabPageControllerPixelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF9AD442CE766F700C5A406 /* NewTabPageControllerPixelTests.swift */; }; 7B1604E82CB685B400A44EC6 /* Logger+TipKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1604E72CB685B400A44EC6 /* Logger+TipKit.swift */; }; 7B1604EC2CB68BDA00A44EC6 /* TipKitController+ConvenienceInitializers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1604EB2CB68BDA00A44EC6 /* TipKitController+ConvenienceInitializers.swift */; }; 7B1604EE2CB68D2600A44EC6 /* TipKitDebugOptionsUIActionHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1604ED2CB68D2600A44EC6 /* TipKitDebugOptionsUIActionHandling.swift */; }; @@ -1679,9 +1679,9 @@ 6FEC0B842C999352006B4F6E /* FavoriteItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteItem.swift; sourceTree = ""; }; 6FEC0B872C999961006B4F6E /* FavoritesListInteractingAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesListInteractingAdapter.swift; sourceTree = ""; }; 6FF915802B88E0750042AC87 /* AdAttributionFetcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdAttributionFetcherTests.swift; sourceTree = ""; }; - 6FF9AD442CE766F700C5A406 /* NewTabPageControllerPixelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageControllerPixelTests.swift; sourceTree = ""; }; 6FF9AD3E2CE63DC200C5A406 /* TabSwitcherOpenDailyPixel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabSwitcherOpenDailyPixel.swift; sourceTree = ""; }; 6FF9AD402CE6610600C5A406 /* TabSwitcherDailyPixelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabSwitcherDailyPixelTests.swift; sourceTree = ""; }; + 6FF9AD442CE766F700C5A406 /* NewTabPageControllerPixelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageControllerPixelTests.swift; sourceTree = ""; }; 7B1604E72CB685B400A44EC6 /* Logger+TipKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+TipKit.swift"; sourceTree = ""; }; 7B1604EB2CB68BDA00A44EC6 /* TipKitController+ConvenienceInitializers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TipKitController+ConvenienceInitializers.swift"; sourceTree = ""; }; 7B1604ED2CB68D2600A44EC6 /* TipKitDebugOptionsUIActionHandling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipKitDebugOptionsUIActionHandling.swift; sourceTree = ""; }; @@ -11053,8 +11053,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { - kind = exactVersion; - version = 211.1.2; + kind = revision; + revision = b2bdcc7fedf176fbf167d17bd76e25e488e71b86; }; }; 9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 99e58d2d10..e02a1b9a67 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/DuckDuckGo/BrowserServicesKit", "state" : { - "revision" : "deacf613553334f35053a2092d4e062e4775544c", - "version" : "211.1.2" + "revision" : "b2bdcc7fedf176fbf167d17bd76e25e488e71b86" } }, { From f7b0998ab466027daec09b1a729462e488311881 Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Mon, 25 Nov 2024 22:18:01 +0600 Subject: [PATCH 2/4] fix build --- DuckDuckGo/MainViewController.swift | 6 +++--- DuckDuckGo/TabViewController.swift | 6 +++--- DuckDuckGoTests/ContextualDaxDialogsFactoryTests.swift | 6 +++--- .../ContextualOnboardingNewTabDialogFactoryTests.swift | 4 ++-- DuckDuckGoTests/ContextualOnboardingPresenterTests.swift | 4 ++-- DuckDuckGoTests/OnboardingNavigationDelegateTests.swift | 4 ++-- DuckDuckGoTests/TabViewControllerDaxDialogTests.swift | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 8a51278c6f..e078844e49 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -2821,11 +2821,11 @@ extension MainViewController: OnboardingDelegate { } extension MainViewController: OnboardingNavigationDelegate { - func navigateTo(url: URL) { + func navigateFromOnboarding(to url: URL) { self.loadUrl(url, fromExternalLink: true) } - - func searchFor(_ query: String) { + + func searchFromOnboarding(for query: String) { self.loadQuery(query) } } diff --git a/DuckDuckGo/TabViewController.swift b/DuckDuckGo/TabViewController.swift index a5bbd41846..f755becbf9 100644 --- a/DuckDuckGo/TabViewController.swift +++ b/DuckDuckGo/TabViewController.swift @@ -3080,12 +3080,12 @@ extension TabViewController: SaveLoginViewControllerDelegate { } extension TabViewController: OnboardingNavigationDelegate { - - func searchFor(_ query: String) { + + func searchFromOnboarding(for query: String) { delegate?.tab(self, didRequestLoadQuery: query) } - func navigateTo(url: URL) { + func navigateFromOnboarding(to url: URL) { delegate?.tab(self, didRequestLoadURL: url) } diff --git a/DuckDuckGoTests/ContextualDaxDialogsFactoryTests.swift b/DuckDuckGoTests/ContextualDaxDialogsFactoryTests.swift index f1c406cea8..bcc9373111 100644 --- a/DuckDuckGoTests/ContextualDaxDialogsFactoryTests.swift +++ b/DuckDuckGoTests/ContextualDaxDialogsFactoryTests.swift @@ -484,12 +484,12 @@ final class ContextualOnboardingDelegateMock: ContextualOnboardingDelegate { func didTapDismissContextualOnboardingAction() { didCallDidTapDismissContextualOnboardingAction = true } - - func searchFor(_ query: String) { + + func searchFromOnboarding(for query: String) { didCallSearchForQuery = true } - func navigateTo(url: URL) { + func navigateFromOnboarding(to url: URL) { didCallNavigateToURL = true urlToNavigateTo = url } diff --git a/DuckDuckGoTests/ContextualOnboardingNewTabDialogFactoryTests.swift b/DuckDuckGoTests/ContextualOnboardingNewTabDialogFactoryTests.swift index 609be206a5..1d08a5c9ef 100644 --- a/DuckDuckGoTests/ContextualOnboardingNewTabDialogFactoryTests.swift +++ b/DuckDuckGoTests/ContextualOnboardingNewTabDialogFactoryTests.swift @@ -294,11 +294,11 @@ class CapturingOnboardingNavigationDelegate: OnboardingNavigationDelegate { var suggestedSearchQuery: String? var urlToNavigateTo: URL? - func searchFor(_ query: String) { + func searchFromOnboarding(for query: String) { suggestedSearchQuery = query } - func navigateTo(url: URL) { + func navigateFromOnboarding(to url: URL) { urlToNavigateTo = url } } diff --git a/DuckDuckGoTests/ContextualOnboardingPresenterTests.swift b/DuckDuckGoTests/ContextualOnboardingPresenterTests.swift index 8575dd6692..5220b6dff9 100644 --- a/DuckDuckGoTests/ContextualOnboardingPresenterTests.swift +++ b/DuckDuckGoTests/ContextualOnboardingPresenterTests.swift @@ -210,12 +210,12 @@ final class TabViewControllerMock: UIViewController, TabViewOnboardingDelegate { didCallDidTapDismissAction = true } - func searchFor(_ query: String) { + func searchFromOnboarding(for query: String) { didCallSearchForQuery = true capturedQuery = query } - func navigateTo(url: URL) { + func navigateFromOnboarding(to url: URL) { didCallNavigateToURL = true capturedURL = url } diff --git a/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift b/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift index 52e2da5b9a..2cc6823ece 100644 --- a/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift +++ b/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift @@ -106,7 +106,7 @@ final class OnboardingNavigationDelegateTests: XCTestCase { let expectedUrl = try XCTUnwrap(URL.makeSearchURL(query: query, queryContext: nil)) // WHEN - mainVC.searchFor(query) + mainVC.searchFromOnboarding(for: query) // THEN assertExpected(queryURL: expectedUrl) @@ -118,7 +118,7 @@ final class OnboardingNavigationDelegateTests: XCTestCase { let expectedUrl = try XCTUnwrap(URL(string: site)) // WHEN - mainVC.navigateTo(url: expectedUrl) + mainVC.navigateFromOnboarding(to: expectedUrl) // THEN assertExpected(url: expectedUrl) diff --git a/DuckDuckGoTests/TabViewControllerDaxDialogTests.swift b/DuckDuckGoTests/TabViewControllerDaxDialogTests.swift index 1e22244892..50fbeac8b9 100644 --- a/DuckDuckGoTests/TabViewControllerDaxDialogTests.swift +++ b/DuckDuckGoTests/TabViewControllerDaxDialogTests.swift @@ -55,7 +55,7 @@ final class TabViewControllerDaxDialogTests: XCTestCase { XCTAssertNil(delegateMock.capturedQuery) // WHEN - sut.searchFor(query) + sut.searchFromOnboarding(for: query) // THEN XCTAssertTrue(delegateMock.didRequestLoadQueryCalled) @@ -68,7 +68,7 @@ final class TabViewControllerDaxDialogTests: XCTestCase { XCTAssertNil(delegateMock.capturedURL) // WHEN - sut.navigateTo(url: .ddg) + sut.navigateFromOnboarding(to: .ddg) // THEN XCTAssertTrue(delegateMock.didRequestLoadURLCalled) From 0e223359481f29cfd3f49269f2c21b516d147390 Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Tue, 3 Dec 2024 16:55:33 +0500 Subject: [PATCH 3/4] Malware protection 5: Refactor Special Error Types (#3642) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/481882893211075/1208033567421351/f BSK PR: https://github.com/duckduckgo/BrowserServicesKit/pull/1098 macOS PR: https://github.com/duckduckgo/macos-browser/pull/3603 **Description**: - Update Error Data type to match macOS **Steps to test this PR**: 1. Validate on badssl.com that bad SSL error handling works as before and error page + bypass works **Definition of Done (Internal Only)**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? **Copy Testing**: * [ ] Use of correct apostrophes in new copy, ie `’` rather than `'` **Orientation Testing**: * [ ] Portrait * [ ] Landscape **Device Testing**: * [ ] iPhone SE (1st Gen) * [ ] iPhone 8 * [ ] iPhone X * [ ] iPhone 14 Pro * [ ] iPad **OS Testing**: * [ ] iOS 15 * [ ] iOS 16 * [ ] iOS 17 **Theme Testing**: * [ ] Light theme * [ ] Dark theme --- ###### Internal references: [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) --- DuckDuckGo/TabViewController.swift | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/DuckDuckGo/TabViewController.swift b/DuckDuckGo/TabViewController.swift index f755becbf9..cca6e04272 100644 --- a/DuckDuckGo/TabViewController.swift +++ b/DuckDuckGo/TabViewController.swift @@ -1705,20 +1705,16 @@ extension TabViewController: WKNavigationDelegate { private func loadSpecialErrorPageIfNeeded(error: NSError) { guard featureFlagger.isFeatureOn(.sslCertificatesBypass), - error.code == NSURLErrorServerCertificateUntrusted, - let errorCode = error.userInfo["_kCFStreamErrorCodeKey"] as? Int32, - let failedURL = error.failedUrl else { - return - } + error.isServerCertificateUntrusted, + let errorType = error.sslErrorType, + let failedURL = error.failedUrl, + let host = failedURL.host else { return } + let tld = storageCache.tld - let errorType = SSLErrorType.forErrorCode(Int(errorCode)) self.failedURL = failedURL - errorData = SpecialErrorData(kind: .ssl, - errorType: errorType.rawValue, - domain: failedURL.host, - eTldPlus1: tld.eTLDplus1(failedURL.host)) + errorData = SpecialErrorData.ssl(type: errorType, domain: host, eTldPlus1: tld.eTLDplus1(host)) loadSpecialErrorPage(url: failedURL) - Pixel.fire(pixel: .certificateWarningDisplayed(errorType.rawParameter)) + Pixel.fire(pixel: .certificateWarningDisplayed(errorType.pixelParameter)) } private func loadSpecialErrorPage(url: URL) { @@ -3138,7 +3134,7 @@ extension UserContentController { extension TabViewController: SpecialErrorPageUserScriptDelegate { - func leaveSite() { + func leaveSiteAction() { Pixel.fire(pixel: .certificateWarningLeaveClicked) guard webView?.canGoBack == true else { delegate?.tabDidRequestClose(self) @@ -3147,7 +3143,7 @@ extension TabViewController: SpecialErrorPageUserScriptDelegate { _ = webView?.goBack() } - func visitSite() { + func visitSiteAction() { Pixel.fire(pixel: .certificateWarningProceedClicked) isSpecialErrorPageVisible = false shouldBypassSSLError = true From c0928b7591b4c0805f7f3e8d6a4f716fbf851b6b Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Tue, 3 Dec 2024 18:12:53 +0600 Subject: [PATCH 4/4] BSK -> 217.0.0 --- DuckDuckGo.xcodeproj/project.pbxproj | 4 ++-- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 926c337702..206bd1dc29 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -11312,8 +11312,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { - kind = revision; - revision = b226cb24dccdabec71f102e53c19e9ccb340dba7; + kind = exactVersion; + version = 217.0.0; }; }; 9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 76bee033a1..f2444396db 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,7 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/DuckDuckGo/BrowserServicesKit", "state" : { - "revision" : "b226cb24dccdabec71f102e53c19e9ccb340dba7" + "revision" : "befc1f1094353d8d88a99ac08885684c978b2016", + "version" : "217.0.0" } }, {