Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Never select a folder holding a KeePass database or its key file

Țugui Dragoș0176a8dc6ac3
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 58414cac..f78250d5 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -82806,6 +82806,112 @@
}
}
},
+ "Not selected: a password database or its key file is inside. Once the Trash is emptied, the passwords are gone for good unless you have a backup." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nevybráno: uvnitř je databáze hesel nebo soubor s klíčem k ní. Jakmile se koš vysype, hesla budou trvale ztracena, pokud nemáte zálohu."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicht ausgewählt: Darin liegt eine Passwortdatenbank oder ihre Schlüsseldatei. Sobald der Papierkorb entleert ist, sind die Passwörter endgültig verloren, sofern du kein Backup hast."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sin seleccionar: dentro hay una base de datos de contraseñas o su archivo de clave. En cuanto se vacíe la papelera, las contraseñas se perderán definitivamente, salvo que tengas una copia de seguridad."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non sélectionné : il contient une base de données de mots de passe ou son fichier-clé. Une fois la corbeille vidée, les mots de passe sont perdus définitivement, sauf si vous en avez une sauvegarde."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non selezionato: all’interno c’è un database di password o il suo file chiave. Una volta svuotato il Cestino, le password sono perse definitivamente, a meno che tu non abbia un backup."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選択: 中にパスワードデータベースまたはそのキーファイルがあります。ゴミ箱を空にすると、バックアップがない限り、パスワードは二度と取り戻せなくなります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "선택되지 않음: 안에 암호 데이터베이스나 해당 키 파일이 있습니다. 휴지통을 비우면 백업이 없는 한 암호가 영구적으로 사라집니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niet geselecteerd: er zit een wachtwoorddatabase of het sleutelbestand ervan in. Zodra de prullenmand is geleegd, zijn de wachtwoorden definitief weg, tenzij je een back-up hebt."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie zaznaczono: w środku jest baza haseł lub jej plik klucza. Po opróżnieniu Kosza hasła przepadną na zawsze, chyba że masz backup."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não selecionado: há dentro um banco de dados de senhas ou o arquivo-chave dele. Depois que o Lixo for esvaziado, as senhas se perdem definitivamente, a menos que você tenha um backup."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neselectat: înăuntru se află o bază de date cu parole sau fișierul cheie al acesteia. După golirea Coșului, parolele se pierd definitiv, dacă nu aveți un backup."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не выбрано: внутри есть база данных паролей или ее файл-ключ. После очистки Корзины пароли будут потеряны безвозвратно, если у Вас нет резервной копии."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inte markerad: en lösenordsdatabas eller dess nyckelfil ligger i den. När papperskorgen har tömts är lösenorden borta för alltid, om du inte har en säkerhetskopia."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seçilmedi: içinde bir parola veritabanı veya onun anahtar dosyası var. Çöp Sepeti boşaltıldığında, yedeklemeniz yoksa parolalar kalıcı olarak gider."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не вибрано: усередині є база даних паролів або її файл-ключ. Коли Смітник буде очищено, паролі буде втрачено назавжди, якщо у вас немає резервної копії."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未选择:其中有密码数据库或其密钥文件。一旦清倒废纸篓,除非你有备份,否则这些密码将永久丢失。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選取:其中有密碼資料庫或其金鑰檔案。一旦清空「垃圾桶」,除非你有備份,否則這些密碼就會永久消失。"
+ }
+ }
+ }
+ },
"Not selected: a program has this open right now, and may still be downloading it." : {
"localizations" : {
"cs" : {
@@ -88426,12 +88532,6 @@
},
"Once %@ leaves the Applications folder, its own service uninstalls it: it logs this Mac out of your account and deletes its settings, which History can’t bring back. Write down your account number first, or run the app’s own uninstaller instead: `%@`." : {
"localizations" : {
- "en" : {
- "stringUnit" : {
- "state" : "new",
- "value" : "Once %1$@ leaves the Applications folder, its own service uninstalls it: it logs this Mac out of your account and deletes its settings, which History can’t bring back. Write down your account number first, or run the app’s own uninstaller instead: `%2$@`."
- }
- },
"cs" : {
"stringUnit" : {
"state" : "translated",
@@ -88444,6 +88544,12 @@
"value" : "Sobald %@ den Ordner „Programme“ verlässt, wird die App von ihrem eigenen Dienst deinstalliert: Er meldet diesen Mac von deinem Account ab und löscht ihre Einstellungen, die sich über den Verlauf nicht zurückholen lassen. Notiere dir zuerst deine Accountnummer oder führe stattdessen das eigene Deinstallationsprogramm der App aus: `%@`."
}
},
+ "en" : {
+ "stringUnit" : {
+ "state" : "new",
+ "value" : "Once %1$@ leaves the Applications folder, its own service uninstalls it: it logs this Mac out of your account and deletes its settings, which History can’t bring back. Write down your account number first, or run the app’s own uninstaller instead: `%2$@`."
+ }
+ },
"es" : {
"stringUnit" : {
"state" : "translated",
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 145950da..f9d0b277 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -315,6 +315,7 @@ extension HoldBack {
case .holdsDocuments: "holds the app's documents"
case .holdsALibrary: "holds a photo, music, or video library"
case .holdsAWallet: "holds a wallet or a signing key"
+ case .holdsAPasswordDatabase: "holds a password database or its key file"
case .holdsLocalMail: "may hold mail kept only on this Mac"
case .holdsMessageHistory: "holds message history that may exist only on this Mac"
case .holdsPasswordsOrCodes: "holds passwords or sign-in codes that may exist only on this Mac"
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 04ca4b20..d4f379d4 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -51,6 +51,8 @@ public enum HoldBack: String, Sendable, Hashable {
case holdsALibrary
/// A cryptocurrency wallet or a signing key is inside, which may exist nowhere else.
case holdsAWallet
+ /// A password database or its key file is inside, which may exist nowhere else.
+ case holdsAPasswordDatabase
/// Mail kept on this Mac may be inside, such as a local or POP account's (`KeptOnlyHere`).
case holdsLocalMail
/// Message history that may exist only on this Mac (`KeptOnlyHere`).
@@ -101,6 +103,7 @@ public enum HoldBack: String, Sendable, Hashable {
guard let contents else { return .notMeasured }
if contents.couldNotBeRead { return .couldNotBeRead }
if contents.holdsWallet { return .holdsAWallet }
+ if contents.holdsPasswordDatabase { return .holdsAPasswordDatabase }
return contents.holdsRepository ? .holdsRepository : nil
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
index 7393735a..c98be722 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
@@ -347,6 +347,7 @@ public struct LeftoverScanner: Sendable {
// A wallet comes first: a cask's `zap` can name a coin app's whole data folder, which is where its keys
// are. Holding it back costs a checkmark, and the row says what is inside.
if contents.holdsWallet { return .holdsAWallet }
+ if contents.holdsPasswordDatabase { return .holdsAPasswordDatabase }
if contents.holdsRepository { return .holdsRepository }
if kind == .logs, CrashReport.isOne(url) { return .crashReport }
if kind == .sharedFolder { return .sharedWithEveryone }
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift b/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
index cd10d1af..9f315348 100644
--- a/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
@@ -13,6 +13,8 @@ public struct FolderContents: Sendable, Hashable {
/// True when a cryptocurrency wallet or a signing key was seen inside (`isWallet(_:)`). Without the file
/// or a written recovery phrase, the money or the key is gone for good.
public let holdsWallet: Bool
+ /// True when a password database or its key file was seen inside (`isPasswordDatabase(_:)`).
+ public let holdsPasswordDatabase: Bool
/// The latest modification date of anything inside. A folder's own date does not change when a file in
/// it is rewritten in place.
public let newestChange: Date?
@@ -25,12 +27,14 @@ public struct FolderContents: Sendable, Hashable {
size: Int64,
holdsRepository: Bool,
holdsWallet: Bool = false,
+ holdsPasswordDatabase: Bool = false,
newestChange: Date? = nil,
couldNotBeRead: Bool = false
) {
self.size = size
self.holdsRepository = holdsRepository
self.holdsWallet = holdsWallet
+ self.holdsPasswordDatabase = holdsPasswordDatabase
self.newestChange = newestChange
self.couldNotBeRead = couldNotBeRead
}
@@ -142,6 +146,7 @@ public enum FileSize {
size: (values.linkCount ?? 1) > 1 ? 0 : freed(by: url, values),
holdsRepository: repositoryMarkers.contains(url.lastPathComponent),
holdsWallet: isWallet(url.lastPathComponent),
+ holdsPasswordDatabase: isPasswordDatabase(url.lastPathComponent),
newestChange: values.contentModificationDate
)
} catch CocoaError.fileReadNoSuchFile {
@@ -187,6 +192,7 @@ public enum FileSize {
// The folder's own name counts as its entries' do: a `keystore` or a `.git` measured on its own.
var holdsRepository = repositoryMarkers.contains(url.lastPathComponent)
var holdsWallet = isWallet(url.lastPathComponent)
+ var holdsPasswordDatabase = isPasswordDatabase(url.lastPathComponent)
var newestChange: Date?
// A file with several names goes only once every name has gone, so it counts once, and only when all of
// its names are inside.
@@ -202,6 +208,7 @@ public enum FileSize {
// `.git` folder.
if repositoryMarkers.contains(file.lastPathComponent) { holdsRepository = true }
if isWallet(file.lastPathComponent) { holdsWallet = true }
+ if isPasswordDatabase(file.lastPathComponent) { holdsPasswordDatabase = true }
guard let values = try? file.resourceValues(forKeys: fileKeys) else { return .next }
if let written = values.contentModificationDate, written > newestChange ?? .distantPast {
newestChange = written
@@ -228,6 +235,7 @@ public enum FileSize {
size: total,
holdsRepository: holdsRepository,
holdsWallet: holdsWallet,
+ holdsPasswordDatabase: holdsPasswordDatabase,
newestChange: newestChange,
couldNotBeRead: refused.happened
)
@@ -286,6 +294,13 @@ public enum FileSize {
private static let walletSuffixes = ["wallet.dat", ".legacy.bak", ".wallet", ".keys", ".mmdbdoc_v1", ".jmdat"]
private static let walletPrefixes = ["wallet.dat.", "zecwallet-light-wallet.backup."]
+
+ /// True for a KeePass database (`.kdbx`) or a KeePassXC key file (`.keyx`), without which the database
+ /// cannot be opened.
+ static func isPasswordDatabase(_ name: String) -> Bool {
+ let name = name.lowercased()
+ return name.hasSuffix(".kdbx") || name.hasSuffix(".keyx")
+ }
}
/// What is known about the folders being walked.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
index 8f79ce41..ccab75a0 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
@@ -470,6 +470,15 @@ struct FileSizeTests {
}
}
+ @Test func knowsAPasswordDatabaseAndItsKeyFile() {
+ for name in ["Passwords.kdbx", "VAULT.KDBX", "Vault.keyx"] {
+ #expect(FileSize.isPasswordDatabase(name), "\(name)")
+ }
+ for name in ["Passwords.kdbx.lock", "notes.key", "kdbx", "Passwords.kdb"] {
+ #expect(!FileSize.isPasswordDatabase(name), "\(name)")
+ }
+ }
+
/// A folder whose contents are only in the cloud is skipped: listing it fetches the whole tree from the
/// provider and adds nothing, since it holds no local bytes. Ordinary folders are not dataless.
@Test func doesNotWalkIntoAFolderThatIsOnlyInTheCloud() throws {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 76a329d3..99ed9b34 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -1449,6 +1449,19 @@ struct LeftoverScannerTests {
#expect(scan.leftovers.first?.match.confidence == .certain)
}
+ @Test func aFolderWithAPasswordDatabaseOrItsKeyFileIsNeverSelected() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Application Support/Tunewell/Backups/Passwords.kdbx")
+ try directory.file("home/Library/Application Support/net.example.client/Vault.keyx")
+
+ let scanner = LeftoverScanner(environment: environment(in: directory))
+
+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])
+ let held = scan.leftovers.filter { ["Tunewell", "net.example.client"].contains($0.url.lastPathComponent) }
+ #expect(held.count == 2)
+ #expect(held.allSatisfy { $0.match.heldBack == .holdsAPasswordDatabase && !$0.match.isRecommended })
+ }
+
@Test func dataKeptOnlyOnThisMacIsShownAndNeverSelected() async throws {
let directory = try TemporaryDirectory()
try directory.file("home/Library/Application Support/Signal/sql/db.sqlite", bytes: 4_096)
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index d8c43d7c..3de1aada 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -225,6 +225,8 @@ extension HoldBack {
"Left alone: a photo, music, or video library is inside, so Peel leaves this folder where it is."
case .holdsAWallet:
"Not selected: a wallet or a signing key is inside. Once the Trash is emptied, what it opens is gone for good unless you have a backup."
+ case .holdsAPasswordDatabase:
+ "Not selected: a password database or its key file is inside. Once the Trash is emptied, the passwords are gone for good unless you have a backup."
case .holdsLocalMail:
"Not selected: this may hold mail kept only on this Mac, such as a local or POP account’s. Once the Trash is emptied, it’s gone for good unless you have a backup."
case .holdsMessageHistory:
diff --git a/SAFETY.md b/SAFETY.md
index 944855f7..c7776ffa 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -177,7 +177,8 @@ devices, both needed to read crash reports, model weights, the packages a tool k
virtual environments, the installers and boxes a tool keeps for you to install again, a cache macOS keeps for its own
services in `~/Library/Caches` (Spotlight's, iCloud's, the fonts') or in the container of one of Apple's apps,
`/Users/Shared` (it belongs to every account, not just yours), a project you worked on this week, a folder with a
-repository, a wallet, or a signing key inside, what an app keeps that may exist only on this Mac (local mail, message
+repository, a wallet, a signing key, or a password database (KeePass's `.kdbx`, KeePassXC's `.keyx`) inside, what an
+app keeps that may exist only on this Mac (local mail, message
history, a password manager's backups and an authenticator's codes, VPN connections, each where the app's own
documentation or source says it keeps them), a folder macOS would not let Peel read, and a folder Peel could not
measure in time. Those last two are shown with their size as "Unknown", never as zero, in every tool and in History
@@ -197,9 +198,9 @@ one by hand, and so is Terraform's `.terraform`, which keeps the workspace you c
on its own, such as `target` or `build`, is listed and never selected either.
Orphaned Files selects nothing for you, and `peel orphans --remove` leaves these folders out as well: one in
-`/Users/Shared`, one with a repository, a wallet, or a signing key inside, one that may hold what exists only on this
-Mac, or one Peel could not read or measure in time, moves only when you select it yourself. Select All selects such a
-folder too only after asking, with how many items Peel doesn't recommend removing.
+`/Users/Shared`, one with a repository, a wallet, a signing key, or a password database inside, one that may hold what
+exists only on this Mac, or one Peel could not read or measure in time, moves only when you select it yourself. Select
+All selects such a folder too only after asking, with how many items Peel doesn't recommend removing.
In Duplicates, one copy of every group always stays, and a file that changed since the scan is refused. Nothing
inside an app or another package is ever offered, nor a hidden folder, such as a tool's settings in `~/.config`: