Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Keep a browser profile whose wallet storage cannot be listed
Țugui Dragoș8f310f3cdf7a
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift b/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swiftindex e5905065..37f06b39 100644--- a/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift+++ b/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift@@ -283,10 +283,17 @@ extension ProtectedData {}/// True for a browser profile that holds a wallet: a wallet extension's storage, a wallet add-on, or Brave's own- /// wallet in its `Preferences`.+ /// wallet in its `Preferences`. A storage folder that is there and cannot be listed is not known to hold no wallet,+ /// so it counts as one: macOS can refuse to list the data malicious software goes after while it still answers+ /// `lstat`.private static func isAProfileWithAWallet(_ profile: String) -> Bool {for folder in ["Local Extension Settings", "IndexedDB", "extensions"] {- let names = (try? FileManager.default.contentsOfDirectory(atPath: profile + "/" + folder)) ?? []+ let path = profile + "/" + folder+ guard let names = try? FileManager.default.contentsOfDirectory(atPath: path) else {+ var info = stat()+ if lstat(path, &info) == 0, info.st_mode & S_IFMT == S_IFDIR { return true }+ continue+ }if names.contains(where: { isAWalletsStorage($0.lowercased(), in: folder.lowercased()) }) { return true }}return holdsBravesWallet(profile + "/Preferences")diff --git a/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift b/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swiftindex 6e3c5020..10ccab43 100644--- a/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift+++ b/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift@@ -7,7 +7,7 @@ public enum HelperIdentity {public static let launchdPlistName = "com.tuguidragos.Peel.Helper.plist"/// Raise it whenever the helper changes, so Peel asks for the helper to be installed again rather than work with/// an older one. The helper refuses requests that carry any other version.- public static let protocolVersion = 9+ public static let protocolVersion = 10}/// The complete set of privileged operations. The helper validates every argument itself.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swiftindex c796a9b0..8d539758 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift@@ -99,6 +99,20 @@ struct BrowserWalletTests {}/// Brave keeps its own wallet's encrypted recovery phrase in the profile's `Preferences`.+ /// A wallet's storage that macOS will not let Peel list is not known to hold no wallet, so the profile stays.+ @Test(.permissionsHold) func aWalletStorageThatCannotBeListedKeepsItsProfile() throws {+ let directory = try TemporaryDirectory()+ let profile = try directory.directory("Chrome/Default")+ try directory.directory("Chrome/Default/Local Extension Settings")+ try directory.setPermissions(0, of: "Chrome/Default/Local Extension Settings")+ defer { try? directory.setPermissions(0o755, of: "Chrome/Default/Local Extension Settings") }+ let plain = try directory.directory("Other/Default")+ try directory.directory("Other/Default/Local Extension Settings")++ #expect(ProtectedData.holdsABrowserWallet(profile.path(percentEncoded: false)))+ #expect(!ProtectedData.holdsABrowserWallet(plain.path(percentEncoded: false)))+ }+@Test func bravesOwnWalletKeepsItsProfile() throws {let directory = try TemporaryDirectory()let brave = "home/Library/Application Support/BraveSoftware/Brave-Browser"diff --git a/SAFETY.md b/SAFETY.mdindex 87b3562e..0e0ca68c 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -232,8 +232,9 @@ A wallet's keys can be the only way to what they hold, so Peel keeps them in foubrowser's profile, beside `Local Storage`, which every extension shares. So a profile that holds one of thewallet extensions Peel knows (those of more than 60 wallets, for Chrome, Brave, Edge, Arc, Opera, Vivaldi, andFirefox) or Brave's own wallet stays, and so does a folder that holds it a level or two down, which is where a- browser keeps its profiles (`Google/Chrome/Default`): uninstalling a browser never takes its wallet. The rest of- what a browser keeps, such as its caches, can still go.+ browser keeps its profiles (`Google/Chrome/Default`): uninstalling a browser never takes its wallet. A profile+ whose extension storage macOS will not let Peel list stays too, since it is not known to hold no wallet. The rest+ of what a browser keeps, such as its caches, can still go.- **A wallet found anywhere else is never selected for you.** When an uninstall or Orphaned Files measures afolder, it also looks inside for the names wallets and key tools give their files: anything called`wallet.dat`, `wallets`, `keystore`, `seed.dat`, `hsm_secret`, or `channel.backup`, anything ending in `.wallet`