Skip to content

Commit

Permalink
add creation and modified dates to the keychain debug screen (duckduc…
Browse files Browse the repository at this point in the history
…kgo#1973)

Task/Issue URL: https://app.asana.com/0/414709148257752/1205415059499063
Tech Design URL:
CC:

Description:

Adds creation and modified dates to the keychain debug screen.

Steps to test this PR:

Run the app and create some keychain entries (autofill, email, etc)
Check the keychain debug screen shows the creation / modification dates
  • Loading branch information
brindy authored Sep 4, 2023
1 parent 219159b commit 01ff769
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions DuckDuckGo/KeychainItemsDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private struct KeychainItem {
let service: String?
let account: String?
let valueData: Data?
let creationDate: Any?
let modificationDate: Any?

var value: String? {
guard let valueData = valueData else { return nil }
Expand All @@ -39,6 +41,8 @@ private struct KeychainItem {
Account: \(account ?? "nil")
Value as String: \(value ?? "nil")
Value data: \(String(describing: valueData))
Creation date: \(String(describing: creationDate))
Modification date: \(String(describing: modificationDate))
"""
}
}
Expand Down Expand Up @@ -82,10 +86,12 @@ private enum SecClass: CaseIterable {
}

var items: [KeychainItem]? {
let query: [String: Any] = [kSecClass as String: secClassCFString,
kSecMatchLimit as String: kSecMatchLimitAll,
kSecReturnAttributes as String: true,
kSecReturnRef as String: true]
let query: [String: Any] = [
kSecClass as String: secClassCFString,
kSecMatchLimit as String: kSecMatchLimitAll,
kSecReturnAttributes as String: true,
kSecReturnRef as String: true,
]

var returnArrayRef: CFTypeRef?
let status = SecItemCopyMatching(query as CFDictionary, &returnArrayRef)
Expand All @@ -100,7 +106,9 @@ private enum SecClass: CaseIterable {
KeychainItem(secClass: self,
service: $0[kSecAttrService as String] as? String,
account: $0[kSecAttrAccount as String] as? String,
valueData: $0[kSecValueData as String] as? Data)
valueData: $0[kSecValueData as String] as? Data,
creationDate: $0[kSecAttrCreationDate as String, default: "no creation"],
modificationDate: $0[kSecAttrModificationDate as String, default: "no modification"])
}
}
}
Expand Down

0 comments on commit 01ff769

Please sign in to comment.