Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/7.149.1 #3736

Merged
merged 6 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import SwiftUI
import BrowserServicesKit
import Core
import Common
import os.log

class CredentialProviderViewController: ASCredentialProviderViewController {

Expand Down Expand Up @@ -110,7 +111,9 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
installChildViewController(hostingController)

Task {
await credentialIdentityStoreManager.populateCredentialStore()
if findKeychainItemsWithV4() {
await credentialIdentityStoreManager.populateCredentialStore()
}
}

Pixel.fire(pixel: .autofillExtensionEnabled)
Expand Down Expand Up @@ -203,4 +206,31 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
}
}
}

private func findKeychainItemsWithV4() -> Bool {
var itemsWithV4: [String] = []

let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecReturnAttributes as String: kCFBooleanTrue!,
kSecMatchLimit as String: kSecMatchLimitAll
]

var result: AnyObject?

let status = SecItemCopyMatching(query as CFDictionary, &result)

if status == errSecSuccess, let items = result as? [[String: Any]] {
for item in items {
if let service = item[kSecAttrService as String] as? String,
service.contains("v4") {
itemsWithV4.append(service)
}
}
} else {
Logger.autofill.debug("No items found or error: \(status)")
}

return !itemsWithV4.isEmpty
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Alpha Debug"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
Expand Down
23 changes: 19 additions & 4 deletions DuckDuckGo/AutofillUsageMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,34 @@

import Core
import AuthenticationServices
import BrowserServicesKit

final class AutofillUsageMonitor {

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager? = {
guard let vault = try? AutofillSecureVaultFactory.makeVault(reporter: SecureVaultReporter()) else {
return nil
}

return AutofillCredentialIdentityStoreManager(vault: vault,
tld: AppDependencyProvider.shared.storageCache.tld)
}()

init() {
NotificationCenter.default.addObserver(self, selector: #selector(didReceiveSaveEvent), name: .autofillSaveEvent, object: nil)

ASCredentialIdentityStore.shared.getState({ state in
ASCredentialIdentityStore.shared.getState({ [weak self] state in
if state.isEnabled {
self.autofillExtensionEnabled = true
if self?.autofillExtensionEnabled == nil {
Task {
await self?.credentialIdentityStoreManager?.populateCredentialStore()
}
}
self?.autofillExtensionEnabled = true
} else {
if self.autofillExtensionEnabled != nil {
if self?.autofillExtensionEnabled != nil {
Pixel.fire(pixel: .autofillExtensionDisabled)
self.autofillExtensionEnabled = false
self?.autofillExtensionEnabled = false
}
}
})
Expand Down
Loading