Skip to content

Commit

Permalink
Merge branch 'develop' into sam/import-safari-favorites-correctly
Browse files Browse the repository at this point in the history
# By Alexey Martemyanov (2) and others
# Via GitHub (1) and Tomas Strba (1)
* develop:
  Fix crash on SecureVault corruption (#417)
  ensure app usage is sent (#429)
  Fix non-debug builds (#428)
  new tds url (#430)
  Sparkle 1.27.1 (#411)
  Disable CVDisplayLing logging (#421)
  Version 0.18.7

# Conflicts:
#	DuckDuckGo/Menus/MainMenuActions.swift
  • Loading branch information
samsymons committed Feb 21, 2022
2 parents 4e79cbc + 6288fa0 commit 9a82995
Show file tree
Hide file tree
Showing 24 changed files with 138 additions and 65 deletions.
32 changes: 18 additions & 14 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@
B63ED0E026AFE32F00A9DAD1 /* GeolocationProviderMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63ED0DF26AFE32F00A9DAD1 /* GeolocationProviderMock.swift */; };
B63ED0E326B3E7FA00A9DAD1 /* CLLocationManagerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63ED0E226B3E7FA00A9DAD1 /* CLLocationManagerMock.swift */; };
B63ED0E526BB8FB900A9DAD1 /* SharingMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63ED0E426BB8FB900A9DAD1 /* SharingMenu.swift */; };
B642738227B65BAC0005DFD1 /* SecureVaultErrorReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B642738127B65BAC0005DFD1 /* SecureVaultErrorReporter.swift */; };
B64C84DE2692D7400048FEBE /* PermissionAuthorization.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64C84DD2692D7400048FEBE /* PermissionAuthorization.storyboard */; };
B64C84E32692DC9F0048FEBE /* PermissionAuthorizationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B64C84E22692DC9F0048FEBE /* PermissionAuthorizationViewController.swift */; };
B64C84EB2692DD650048FEBE /* PermissionAuthorizationPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = B64C84EA2692DD650048FEBE /* PermissionAuthorizationPopover.swift */; };
Expand Down Expand Up @@ -1182,6 +1183,7 @@
B63ED0DF26AFE32F00A9DAD1 /* GeolocationProviderMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeolocationProviderMock.swift; sourceTree = "<group>"; };
B63ED0E226B3E7FA00A9DAD1 /* CLLocationManagerMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLLocationManagerMock.swift; sourceTree = "<group>"; };
B63ED0E426BB8FB900A9DAD1 /* SharingMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingMenu.swift; sourceTree = "<group>"; };
B642738127B65BAC0005DFD1 /* SecureVaultErrorReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureVaultErrorReporter.swift; sourceTree = "<group>"; };
B64C84DD2692D7400048FEBE /* PermissionAuthorization.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = PermissionAuthorization.storyboard; sourceTree = "<group>"; };
B64C84E22692DC9F0048FEBE /* PermissionAuthorizationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionAuthorizationViewController.swift; sourceTree = "<group>"; };
B64C84EA2692DD650048FEBE /* PermissionAuthorizationPopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionAuthorizationPopover.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2067,6 +2069,7 @@
85CC1D7826A05E790062F04E /* Model */,
85CC1D7F26A05F6C0062F04E /* Services */,
85CC1D7926A05E820062F04E /* View */,
B642738127B65BAC0005DFD1 /* SecureVaultErrorReporter.swift */,
);
path = SecureVault;
sourceTree = "<group>";
Expand Down Expand Up @@ -3602,7 +3605,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1310;
LastUpgradeCheck = 1320;
ORGANIZATIONNAME = DuckDuckGo;
TargetAttributes = {
4B1AD89C25FC27E200261379 = {
Expand Down Expand Up @@ -4235,6 +4238,7 @@
4B59023D26B35F3600489384 /* ChromeDataImporter.swift in Sources */,
B68C92C42750EF76002AC6B0 /* PixelDataRecord.swift in Sources */,
853014D625E671A000FB8205 /* PageObserverUserScript.swift in Sources */,
B642738227B65BAC0005DFD1 /* SecureVaultErrorReporter.swift in Sources */,
4B139AFD26B60BD800894F82 /* NSImageExtensions.swift in Sources */,
B6A9E45B261460350067D1B9 /* APIHeaders.swift in Sources */,
85625996269C953C00EE44BC /* PasswordManagementViewController.swift in Sources */,
Expand Down Expand Up @@ -4606,15 +4610,15 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.6;
CURRENT_PROJECT_VERSION = 0.18.7;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.6;
MARKETING_VERSION = 0.18.7;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.debug;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -4878,15 +4882,15 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.6;
CURRENT_PROJECT_VERSION = 0.18.7;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.6;
MARKETING_VERSION = 0.18.7;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.debug;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand All @@ -4906,15 +4910,15 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.6;
CURRENT_PROJECT_VERSION = 0.18.7;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.6;
MARKETING_VERSION = 0.18.7;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -5038,7 +5042,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.6;
CURRENT_PROJECT_VERSION = 0.18.7;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREPROCESSOR_DEFINITIONS = "REVIEW=1";
Expand All @@ -5047,7 +5051,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.6;
MARKETING_VERSION = 0.18.7;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.review;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "DuckDuckGo Review";
Expand Down Expand Up @@ -5187,7 +5191,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.6;
CURRENT_PROJECT_VERSION = 0.18.7;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREPROCESSOR_DEFINITIONS = "BETA=1";
Expand All @@ -5196,7 +5200,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.6;
MARKETING_VERSION = 0.18.7;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "DuckDuckGo Non-Production";
Expand Down Expand Up @@ -5339,15 +5343,15 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 8.0.0;
version = 8.0.1;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.26.0;
kind = exactVersion;
version = 1.27.1;
};
};
B65783F325F8ACA400D8DB33 /* XCRemoteSwiftPackageReference "PunycodeSwift" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/duckduckgo/BrowserServicesKit",
"state": {
"branch": null,
"revision": "b86c1669fe4c03480f77f96208a482e2335c08a0",
"version": "8.0.0"
"revision": "56d011b581565d88285dbd6bb68f88e29e985a76",
"version": "8.0.1"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
16 changes: 16 additions & 0 deletions DuckDuckGo/AppDelegate/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,25 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let launchTimingPixel = TimedPixel(.launchTiming)

static var isRunningTests: Bool {
#if DEBUG
ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil
#else
return false
#endif
}

#if DEBUG
let disableCVDisplayLinkLogs: Void = {
// Disable CVDisplayLink logs
CFPreferencesSetValue("cv_note" as CFString,
0 as CFPropertyList,
"com.apple.corevideo" as CFString,
kCFPreferencesCurrentUser,
kCFPreferencesAnyHost)
CFPreferencesSynchronize("com.apple.corevideo" as CFString, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
}()
#endif

let urlEventHandler = URLEventHandler()

private let keyStore = EncryptionKeyStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension NSPopUpButton {
NotificationCenter.default
.publisher(for: NSMenu.didSendActionNotification, object: menu)
.map { _ in self.indexOfSelectedItem }
.prepend(self.indexOfSelectedItem)
.eraseToAnyPublisher()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class BookmarkManagementSplitViewController: NSSplitViewController {
detailViewController.delegate = self
sidebarViewController.tabSwitcherButton.displayBrowserTabButtons(withSelectedTab: .bookmarks)

selectedTabCancellable = sidebarViewController.tabSwitcherButton.selectionPublisher.sink { [weak self] index in
selectedTabCancellable = sidebarViewController.tabSwitcherButton.selectionPublisher.dropFirst().sink { [weak self] index in
self?.delegate?.selectedTab(at: index)
}
}
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/BrowserTab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ extension Tab: SecureVaultManagerDelegate {
Pixel.fire(.formAutofilled(kind: type.formAutofillKind))
}

func secureVaultInitFailed(_ error: SecureVaultError) {
SecureVaultErrorReporter.shared.secureVaultInitFailed(error)
}

}

extension AutofillType {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Configuration/ConfigurationDownloading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum ConfigurationLocation: String, CaseIterable {
case bloomFilterBinary = "https://staticcdn.duckduckgo.com/https/https-mobile-v2-bloom.bin"
case bloomFilterExcludedDomains = "https://staticcdn.duckduckgo.com/https/https-mobile-v2-false-positives.json"
case surrogates = "https://duckduckgo.com/contentblocking.js?l=surrogates"
case trackerRadar = "https://staticcdn.duckduckgo.com/trackerblocking/v2.1/tds.json"
case trackerRadar = "https://staticcdn.duckduckgo.com/trackerblocking/v2.1/apple-tds.json"
case privacyConfiguration = "https://staticcdn.duckduckgo.com/trackerblocking/config/v1/macos-config.json"
// In archived repo, to be refactored shortly (https://staticcdn.duckduckgo.com/useragents/social_ctp_configuration.json)
case FBConfig = "https://staticcdn.duckduckgo.com/useragents/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class SecureVaultLoginImporter: LoginImporter {
}

func importLogins(_ logins: [ImportedLoginCredential]) throws -> DataImport.Summary {
let vault = try SecureVaultFactory.default.makeVault()
let vault = try SecureVaultFactory.default.makeVault(errorReporter: SecureVaultErrorReporter.shared)

var successful: [String] = []
var duplicates: [String] = []
Expand Down
56 changes: 27 additions & 29 deletions DuckDuckGo/Data Import/View/DataImportViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import AppKit
import BrowserServicesKit
import Combine
import os.log

// swiftlint:disable type_body_length
final class DataImportViewController: NSViewController {
Expand Down Expand Up @@ -68,38 +69,39 @@ final class DataImportViewController: NSViewController {
return storyboard.instantiateController(identifier: Constants.identifier)
}

private func secureVaultImporter() throws -> SecureVaultLoginImporter {
let secureVault = try SecureVaultFactory.default.makeVault(errorReporter: SecureVaultErrorReporter.shared)
return SecureVaultLoginImporter(secureVault: secureVault)
}

private var viewState: ViewState = .defaultState() {
didSet {

renderCurrentViewState()

let bookmarkImporter = CoreDataBookmarkImporter(bookmarkManager: LocalBookmarkManager.shared)

switch viewState.selectedImportSource {
case .brave:
let secureVault = try? SecureVaultFactory.default.makeVault()
let secureVaultImporter = SecureVaultLoginImporter(secureVault: secureVault!)
self.dataImporter = BraveDataImporter(loginImporter: secureVaultImporter, bookmarkImporter: bookmarkImporter)
case .chrome:
let secureVault = try? SecureVaultFactory.default.makeVault()
let secureVaultImporter = SecureVaultLoginImporter(secureVault: secureVault!)
self.dataImporter = ChromeDataImporter(loginImporter: secureVaultImporter, bookmarkImporter: bookmarkImporter)
case .edge:
let secureVault = try? SecureVaultFactory.default.makeVault()
let secureVaultImporter = SecureVaultLoginImporter(secureVault: secureVault!)
self.dataImporter = EdgeDataImporter(loginImporter: secureVaultImporter, bookmarkImporter: bookmarkImporter)
case .firefox:
let secureVault = try? SecureVaultFactory.default.makeVault()
let secureVaultImporter = SecureVaultLoginImporter(secureVault: secureVault!)
self.dataImporter = FirefoxDataImporter(loginImporter: secureVaultImporter, bookmarkImporter: bookmarkImporter)
case .safari:
self.dataImporter = SafariDataImporter(bookmarkImporter: bookmarkImporter)
case .csv:
if !(self.dataImporter is CSVImporter) {
self.dataImporter = nil
do {
switch viewState.selectedImportSource {
case .brave:
self.dataImporter = try BraveDataImporter(loginImporter: secureVaultImporter(), bookmarkImporter: bookmarkImporter)
case .chrome:
self.dataImporter = try ChromeDataImporter(loginImporter: secureVaultImporter(), bookmarkImporter: bookmarkImporter)
case .edge:
self.dataImporter = try EdgeDataImporter(loginImporter: secureVaultImporter(), bookmarkImporter: bookmarkImporter)
case .firefox:
self.dataImporter = try FirefoxDataImporter(loginImporter: secureVaultImporter(), bookmarkImporter: bookmarkImporter)
case .safari:
self.dataImporter = SafariDataImporter(bookmarkImporter: bookmarkImporter)
case .csv:
if !(self.dataImporter is CSVImporter) {
self.dataImporter = nil
}
}
} catch {
os_log("dataImporter initialization failed: %{public}s", type: .error, error.localizedDescription)
self.presentAlert(for: .cannotAccessSecureVault)
}

}
}

Expand Down Expand Up @@ -139,11 +141,6 @@ final class DataImportViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()

let secureVault = try? SecureVaultFactory.default.makeVault()
let secureVaultImporter = SecureVaultLoginImporter(secureVault: secureVault!)
let bookmarkImporter = CoreDataBookmarkImporter(bookmarkManager: LocalBookmarkManager.shared)

self.dataImporter = ChromeDataImporter(loginImporter: secureVaultImporter, bookmarkImporter: bookmarkImporter)
importSourcePopUpButton.displayImportSources()
renderCurrentViewState()

Expand Down Expand Up @@ -429,12 +426,13 @@ extension DataImportViewController: CSVImportViewControllerDelegate {
}

do {
let secureVault = try SecureVaultFactory.default.makeVault()
let secureVault = try SecureVaultFactory.default.makeVault(errorReporter: SecureVaultErrorReporter.shared)
let secureVaultImporter = SecureVaultLoginImporter(secureVault: secureVault)
self.dataImporter = CSVImporter(fileURL: url, loginImporter: secureVaultImporter)
self.viewState.interactionState = .ableToImport
} catch {
self.viewState.interactionState = .unableToImport
self.presentAlert(for: .cannotAccessSecureVault)
}
}

Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extension AppDelegate {
savePanel.beginSheetModal(for: window) { response in
guard response == .OK, let selectedURL = savePanel.url else { return }

let vault = try? SecureVaultFactory.default.makeVault()
let vault = try? SecureVaultFactory.default.makeVault(errorReporter: SecureVaultErrorReporter.shared)
let exporter = CSVLoginExporter(secureVault: vault!)
do {
try exporter.exportVaultLogins(to: selectedURL)
Expand Down Expand Up @@ -470,7 +470,7 @@ extension MainViewController {
}

@IBAction func resetSecureVaultData(_ sender: Any?) {
let vault = try? SecureVaultFactory.default.makeVault()
let vault = try? SecureVaultFactory.default.makeVault(errorReporter: SecureVaultErrorReporter.shared)

let accounts = (try? vault?.accounts()) ?? []
for accountID in accounts.compactMap(\.id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class PreferencesSplitViewController: NSSplitViewController {
self?.sidebarViewController.detailViewScrolledTo(rowAtIndex: index)
}.store(in: &cancellables)

sidebarViewController.tabSwitcherButton.selectionPublisher.sink { [weak self] index in
sidebarViewController.tabSwitcherButton.selectionPublisher.dropFirst().sink { [weak self] index in
self?.delegate?.selectedTab(at: index)
}.store(in: &cancellables)
}
Expand Down
Loading

0 comments on commit 9a82995

Please sign in to comment.