Skip to content

Commit

Permalink
Malware protection: bump BSK (#3617)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/481882893211075/1208033567421351/f
BSK PR: duckduckgo/BrowserServicesKit#1091

**Description**:
- BSK bump for macOS phishing detection -> Malicious site protection
rename
  • Loading branch information
mallexxx authored Dec 3, 2024
1 parent a5dab98 commit 19bb35c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11313,7 +11313,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 216.0.1;
version = 217.0.0;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "59f8fb2f850f8a0482c604d07396e01e8de59d21",
"version" : "216.0.1"
"revision" : "befc1f1094353d8d88a99ac08885684c978b2016",
"version" : "217.0.0"
}
},
{
Expand Down Expand Up @@ -138,7 +138,7 @@
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2837,11 +2837,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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ final class UnifiedFeedbackFormViewModel: ObservableObject {

enum Error: String, Swift.Error {
case missingAccessToken
case invalidRequest
case invalidResponse
}

Expand Down Expand Up @@ -297,9 +296,7 @@ final class UnifiedFeedbackFormViewModel: ObservableObject {
problemSubCategory: selectedSubcategory ?? "",
customMetadata: metadata?.toString() ?? "")
let headers = APIRequestV2.HeadersV2(additionalHeaders: [HTTPHeaderKey.authorization: "Bearer \(accessToken)"])
guard let request = APIRequestV2(url: Self.feedbackEndpoint, method: .post, headers: headers, body: payload.toData()) else {
throw Error.invalidRequest
}
let request = APIRequestV2(url: Self.feedbackEndpoint, method: .post, headers: headers, body: payload.toData())

let response: Response = try await apiService.fetch(request: request).decodeBody()
if let error = response.error, !error.isEmpty {
Expand Down
28 changes: 12 additions & 16 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1712,20 +1712,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) {
Expand Down Expand Up @@ -3087,12 +3083,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)
}

Expand Down Expand Up @@ -3145,7 +3141,7 @@ extension UserContentController {

extension TabViewController: SpecialErrorPageUserScriptDelegate {

func leaveSite() {
func leaveSiteAction() {
Pixel.fire(pixel: .certificateWarningLeaveClicked)
guard webView?.canGoBack == true else {
delegate?.tabDidRequestClose(self)
Expand All @@ -3154,7 +3150,7 @@ extension TabViewController: SpecialErrorPageUserScriptDelegate {
_ = webView?.goBack()
}

func visitSite() {
func visitSiteAction() {
Pixel.fire(pixel: .certificateWarningProceedClicked)
isSpecialErrorPageVisible = false
shouldBypassSSLError = true
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGoTests/ContextualDaxDialogsFactoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,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
}
}
4 changes: 2 additions & 2 deletions DuckDuckGoTests/ContextualOnboardingPresenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGoTests/OnboardingNavigationDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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)
Expand All @@ -123,7 +123,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)
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGoTests/TabViewControllerDaxDialogTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class TabViewControllerDaxDialogTests: XCTestCase {
XCTAssertNil(delegateMock.capturedQuery)

// WHEN
sut.searchFor(query)
sut.searchFromOnboarding(for: query)

// THEN
XCTAssertTrue(delegateMock.didRequestLoadQueryCalled)
Expand All @@ -70,7 +70,7 @@ final class TabViewControllerDaxDialogTests: XCTestCase {
XCTAssertNil(delegateMock.capturedURL)

// WHEN
sut.navigateTo(url: .ddg)
sut.navigateFromOnboarding(to: .ddg)

// THEN
XCTAssertTrue(delegateMock.didRequestLoadURLCalled)
Expand Down

0 comments on commit 19bb35c

Please sign in to comment.