Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Commit

Permalink
Integrate Malware protection
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx committed Nov 27, 2024
1 parent 8cb5739 commit 6f29625
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15223,7 +15223,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = revision;
revision = c82310e0352a2ab6df72c9a4d828fac2300cd46a;
revision = 620ce5bbf41b0f41ea54b5dd4c9c1dafb7bf3b89;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "c82310e0352a2ab6df72c9a4d828fac2300cd46a"
"revision" : "620ce5bbf41b0f41ea54b5dd4c9c1dafb7bf3b89"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Bookmarks/Services/BookmarkStoreMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ final class BookmarkStoreMock: BookmarkStore, CustomDebugStringConvertible {
queue.append(contentsOf: folder.children)
}
}
var indexInFavoritesArray = 0
store?.save(entitiesAtIndices: entities.map { ($0, nil, nil) }, completion: { _ in })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ extension MaliciousSiteProtectionManager {
switch (dataType, dataType.threatKind) {
case (.hashPrefixSet, .phishing): "phishingHashPrefixes.json"
case (.filterSet, .phishing): "phishingFilterSet.json"
// case (.hashPrefixes, .malware): "malwareHashPrefixes.json"
// case (.filters, .malware): "malwareFilterSet.json"
case (.hashPrefixSet, .malware): "malwareHashPrefixes.json"
case (.filterSet, .malware): "malwareFilterSet.json"
}
}

Expand All @@ -48,8 +48,8 @@ extension MaliciousSiteProtectionManager {
static let embeddedDataRevision = 1692083
static let phishingEmbeddedHashPrefixDataSHA = "b423fa3cf21d82a8f537ae3c817c7aa5338603401c77a6ed7094f0b20af30055"
static let phishingEmbeddedFilterSetDataSHA = "6633f7a2e521071485128c6bf3b84ce2a2dc7bd09750fed7b0300913ed8bfa96"
// static let malwareEmbeddedHashPrefixDataSHA = "b423fa3cf21d82a8f537ae3c817c7aa5338603401c77a6ed7094f0b20af30055"
// static let malwareEmbeddedFilterSetDataSHA = "6633f7a2e521071485128c6bf3b84ce2a2dc7bd09750fed7b0300913ed8bfa96"
static let malwareEmbeddedHashPrefixDataSHA = "b423fa3cf21d82a8f537ae3c817c7aa5338603401c77a6ed7094f0b20af30055"
static let malwareEmbeddedFilterSetDataSHA = "6633f7a2e521071485128c6bf3b84ce2a2dc7bd09750fed7b0300913ed8bfa96"
}

func revision(for dataType: MaliciousSiteProtection.DataManager.StoredDataType) -> Int {
Expand All @@ -68,8 +68,8 @@ extension MaliciousSiteProtectionManager {
switch (dataType, dataType.threatKind) {
case (.hashPrefixSet, .phishing): Constants.phishingEmbeddedHashPrefixDataSHA
case (.filterSet, .phishing): Constants.phishingEmbeddedFilterSetDataSHA
// case (.hashPrefixes, .malware): Constants.malwareEmbeddedHashPrefixDataSHA
// case (.filters, .malware): Constants.malwareEmbeddedFilterSetDataSHA
case (.hashPrefixSet, .malware): Constants.malwareEmbeddedHashPrefixDataSHA
case (.filterSet, .malware): Constants.malwareEmbeddedFilterSetDataSHA
}
}

Expand All @@ -92,7 +92,7 @@ public class MaliciousSiteProtectionManager: MaliciousSiteDetecting {

init(
fileStoreUrl: URL? = nil,
apiClient: MaliciousSiteProtection.APIClientProtocol = .production,
apiClient: MaliciousSiteProtection.APIClientProtocol = MaliciousSiteProtection.APIClient(environment: .dev),
embeddedDataProvider: MaliciousSiteProtection.EmbeddedDataProviding? = nil,
dataManager: MaliciousSiteProtection.DataManaging? = nil,
detector: MaliciousSiteProtection.MaliciousSiteDetecting? = nil,
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Tab/Navigation/DuckURLSchemeHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private extension DuckURLSchemeHandler {
return
}
let threatKind: MaliciousSiteProtection.ThreatKind = switch reason {
// case .malware: .malware
case .malware: .malware
case .phishing: .phishing
case .ssl: {
assertionFailure("SSL error page is handled with NSURLError: NSURLErrorServerCertificateUntrusted error")
Expand Down
10 changes: 5 additions & 5 deletions DuckDuckGo/Tab/ViewModel/TabViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,16 @@ final class TabViewModel {
var title: String
switch tab.content {
// keep an old tab title for web page terminated page, display "Failed to open page" for loading errors
case _ where isShowingErrorPage && (tab.error?.code != .webContentProcessTerminated || tab.title == nil):
case _ where isShowingErrorPage && (tab.error?.isWebContentProcessTerminated != true || tab.title == nil):
switch tab.error as NSError? {
case let error as URLError? where error?.code == .serverCertificateUntrusted:
case is URLError where tab.error?.isServerCertificateUntrusted == true:
title = UserText.sslErrorPageTabTitle
case .some(let error as MaliciousSiteError):
switch error.code {
case .phishing:
title = UserText.phishingErrorPageTabTitle
// case .malware:
// title = UserText.malwareErrorPageTabTitle
case .malware:
title = UserText.malwareErrorPageTabTitle
}
default:
title = UserText.tabErrorTitle
Expand Down Expand Up @@ -489,7 +489,7 @@ final class TabViewModel {
return .redAlertCircle16
case .some(let error as MaliciousSiteError):
switch error.code {
case .phishing/*, .malware*/:
case .phishing, .malware:
return .redAlertCircle16
}
default:
Expand Down

0 comments on commit 6f29625

Please sign in to comment.