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.

A browser profile with a wallet extension stays, and so does the folder around it

Țugui Dragoș075ca17b6085
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0266ccb7..bc57b307 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -83,6 +83,8 @@ Tests enforce these. If your change makes one of them fail, the rule is right an
- keychains, `~/.ssh`, `~/.gnupg`, `~/.aws`, `~/.password-store`, the signing keys and credentials that
`ProtectedData.homeKeys` names one by one, and the wallet keys that `ProtectedData.walletKeys` names, each
read from the wallet's own documentation or source;
+ - a browser profile that holds a wallet extension's vault or Brave's own wallet, and a folder holding one a
+ level or two down (`ProtectedData.holdsABrowserWallet`);
- Mail, Messages, Safari, Contacts, Calendars, Reminders, Shortcuts, HomeKit, Accounts, Finance,
IdentityServices, FaceTime and call history, Freeform, Journal, Stickies, the passes in Wallet, and every
group container of Apple's own, where macOS keeps notes and other data;
@@ -117,6 +119,10 @@ Tests enforce these. If your change makes one of them fail, the rule is right an
## Changes that need a particular test
- **Matching**: `LeftoverMatcherTests`. A new rule needs the case it catches and a case it must not catch.
+- **A wallet extension**: its ID goes into `BrowserWallets.swift` only in the comment above its SHA-256, never as
+ text the compiler keeps. XProtect, the malware scanner in macOS, takes a binary that carries a few wallet IDs for
+ a program that steals them and moves it to the Trash, a test binary included, so tests read the IDs from those
+ comments (`WalletIDs`). `BrowserWalletTests` checks every fingerprint against the ID above it.
- **The privileged helper**: `PrivilegedPathPolicyTests`, and for a new operation a bump of
`HelperIdentity.protocolVersion`.
- **`DeveloperCaches.definitions`**: a source showing the folder is a cache, and a `DeveloperCachesTests` run.
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
index 87d0d892..d227444d 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
@@ -223,7 +223,8 @@ public struct LeftoverScanner: Sendable {
.couldNotBeRead
} else if kind == .containers, ProtectedData.holdsAContainersDocuments(url.path(percentEncoded: false)) {
.holdsDocuments
- } else if ProtectedData.holds(url.path(percentEncoded: false), home: home) {
+ } else if ProtectedData.holds(url.path(percentEncoded: false), home: home)
+ || ProtectedData.holdsABrowserWallet(url.path(percentEncoded: false)) {
.holdsKeys
} else if ProtectedData.holdsALibrary(url.path(percentEncoded: false)) {
.holdsALibrary
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
index f069af7d..441fde9f 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
@@ -286,7 +286,7 @@ public struct OrphanScanner: Sendable {
let path = url.path(percentEncoded: false)
let heldBack: HoldBack? = if location.kind == .containers, ProtectedData.holdsAContainersDocuments(path) {
.holdsDocuments
- } else if ProtectedData.holds(path, home: home) {
+ } else if ProtectedData.holds(path, home: home) || ProtectedData.holdsABrowserWallet(path) {
.holdsKeys
} else if ProtectedData.holdsALibrary(path) {
.holdsALibrary
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift
index 05648126..299401c1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift
@@ -55,7 +55,8 @@ struct RemovalGuard: Sendable {
// An uninstall lists a whole container, and the documents inside would go with it. Space lists a
// vendor's whole cache folder, and work kept only there (an IDE's local history) would go with it.
guard !ProtectedData.holdsAContainersDocuments(name), !ProtectedData.holdsWorkKeptInACache(name) else { return false }
- guard !ProtectedData.holdsALibrary(name), protectedObjects.allows(name) else { return false }
+ guard !ProtectedData.holdsALibrary(name), !ProtectedData.holdsABrowserWallet(name) else { return false }
+ guard protectedObjects.allows(name) else { return false }
// The rules the helper follows. They protect every account's keychain and mail, not only those of the
// account Peel runs in.
guard !ProtectedData.refuses(name, home: home), !ProtectedData.holds(name, home: home) else { return false }
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift b/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift
new file mode 100644
index 00000000..83e92e3d
--- /dev/null
+++ b/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift
@@ -0,0 +1,299 @@
+import CryptoKit
+import Foundation
+
+/// Wallets that live in a browser profile: the vaults of wallet extensions, and Brave's own wallet. A profile that
+/// holds one stays whole, and so does a folder that holds it a level or two down, because an extension can also
+/// keep its data in the profile's `Local Storage`, which every site and extension share.
+///
+/// The lists hold the SHA-256 of each extension's ID, never the ID itself. XProtect, the malware scanner built into
+/// macOS, knows a program that steals wallets by the extension IDs it carries, and it moves a binary holding a few
+/// of them to the Trash whatever the program does with them (rule `MACOS.SOMA.D` in `XProtect.yara`). Each ID
+/// stays readable in the comment above its fingerprint, which the compiler leaves out of the binary.
+extension ProtectedData {
+ /// The fingerprints of wallet extensions for Chromium browsers, such as Chrome, Brave, Edge, Arc, Opera, and
+ /// Vivaldi, from their listings in the Chrome Web Store and in Edge Add-ons. A listing marked withdrawn is no
+ /// longer served, and an old install can still hold a vault. An ID belongs to one extension, so it matches
+ /// nothing else.
+ public static let walletExtensions: Set<String> = [
+ // Alby: iokeahhehimjnekafflcihljlcjccdbe
+ "54335d136c3d52a7849063542b96b45dde56122a8ea028db0496ccd01ceeabd1",
+ // Ambire: ehgjhhccekdedpbkifaojjaefeohnoea
+ "52c67f71f65000b71ceecf73a606e508a2dbec8cfd324248a62906a83b4dce1c",
+ // Atomic Wallet: gjnckgkfmgmibbkoficdidcljeaaaheg
+ "839eb8389682c393b840d30a1025e05f2bb59c87f6abf77120047b50cfe5c123",
+ // Backpack: aflkmfhebedbjioipglgcbcmnbpgliof
+ "e7f6bfb66b568de853c5f0bad9ec33f9c68bc6d3bdcb412fd46e199ee235eded",
+ // Binance Chain Wallet, withdrawn: fhbohimaelbohpjbbldcngcnapndodjp
+ "05cf49b3dcc0c900cc117a56dd6489e7804fa97c524319eafeaab36c48859a44",
+ // Binance Wallet: cadiboklkpojfamcoggejbbdjcoiljjk
+ "7b233a451838ef932122ea9cf062367ffe6b2d7814ce6a70477e8fe4f39048c2",
+ // Bitget Wallet: jiidiaalihmmhddjgbnbgdfflelocpak
+ "4a163d959b4d8b8692742d31ecab371adcd2fd560329b56ecb8b9126906589af",
+ // Braavos: jnlgamecbpmbajjfhmmmlhejkemejdma
+ "7301cec1871fe9f59326a0c0bac0129e5923a14424985d2c42820d09a4109bbd",
+ // Bybit Wallet: pdliaogehgdbhbnmkklieghmmjkpigpa
+ "ea3f956b26a1dfc1d5f2967b9272e0909c1549eda76ff4acdd836ee8c6824e8d",
+ // Coin98: aeachknmefphepccionboohckonoeemg
+ "49a935e40e34638e94c6ac9205b456a22801d9df6f99947545a2a45300da2d93",
+ // Coin98, from Edge Add-ons, withdrawn: noonkmflgdnoeoelnnhaaphcnoopknig
+ "92bf9a85f16553f1ed9c50ed4249edd0df7a055b8c1527cd93d8c2c606ad6fec",
+ // Coinbase Wallet: hnfanknocfeofbddgcijnmhnfnkdnaad
+ "e139dacc4ebc09c23a854fc51bb619e4bd163a777a08481a0c1b05ef22a2044e",
+ // Coinbase Wallet, from Edge Add-ons, withdrawn: cclgcajjfhcakmjedohnccgmhdddkpfh
+ "0a4ee58131c21e14191c48006ef875ecf82ed96c8889c8081d5c2c95699d101d",
+ // Core: agoakfejjabomempkjlepdflaleeobhb
+ "b0fd706049951b5f8845d34db4957f8b0f3d64be6a9061762f955bfe92a4ff83",
+ // Cosmostation: fpkhgmpbidmiogeglndfbkegfdlnajnf
+ "6c78c1b72ce51bb62a80a8c8becafcfab0f9c0732cc4407666a4a837a4837f8f",
+ // Crypto.com Onchain: hifafgmccdpekplomjjkcfgodnhcellj
+ "1c9163189e844d98a382b1a1c315193f067545c9e08f0b01faa5fef28bff510e",
+ // Crypto.com, from Edge Add-ons, withdrawn: gpbdhlngfkgihnfeekcmkbbalpdflgmg
+ "b981a4075640ef8b2fe365b704725ec219b22076f8de5d2e29011d1d38a7ea57",
+ // Ctrl Wallet, formerly XDEFI: hmeobnfnfcmdkdcmlblgagmfpfboieaf
+ "1e49f207d3e2ba1975c15454b1b1e847d313c21eefd9e6473ccbfaabc0285495",
+ // Enkrypt: kkpllkodjeloidieedojogacfhpaihoh
+ "6ea11db7a23a08f6c0a27e4590b032ec3d9959d4abbabdec4c02c961b4a7fc36",
+ // Enkrypt, from Edge Add-ons: gfenajajnjjmmdojhdjmnngomkhlnfjl
+ "054490f28f0d3036f3c42583713cead8f95bc66258713fee918d61ef24afcaa0",
+ // Eternl: kmhcihpebfmpgmihbkipmjlmmioameka
+ "701beb8085df6d56114489a5763bb9a526f7ce0e05affaf444d42c8356182e16",
+ // Exodus Web3 Wallet: aholpfdialjgjfhomihkjbmgjidlcdno
+ "7f7a23670eb287564aabe14dbbda8f2a88f4c26310390ef7905198cb2512f787",
+ // Guarda: hpglfhgfnhbgpjdenjgmdgoeiappafln
+ "481c38331739261484b3812dfa7ce899b7d8d31b6e3ca3b29310d36b79bf3cdf",
+ // HashPack: gjagmgiddbbciopjhllkdnddhcglnemk
+ "b8f3784dd3405e46d254da4ef3443932264fb92b2c3f8af25f3fb0cb7e0e5a76",
+ // Keplr: dmkamcknogkgcdfhhbddcghachkejeap
+ "16060af3d5f73a20397cf2fbff94071adac10903d0973530265eb6ebc739af7d",
+ // Keplr, from Edge Add-ons: ocodgmmffbkkeecmadcijjhkmeohinei
+ "d45d90a757cafa9e567b03796bdd1f37cbac46d9ac80b3f0d0d73c660a431181",
+ // Lace: gafhhkghbfjjkeiendhlofajokpaflmk
+ "7ac5cdf8c0304d3669fc4716822be6cee0be9543374ffb7631ea0d8efbe80f54",
+ // Leap Cosmos Wallet, withdrawn: fcfcfllfndlomdhbehjjcoimbgofdncg
+ "da6d3fab11d6ad615ea2cc70ec2e35f98d1f54393089ce02f1e00422019420c5",
+ // Leather: ldinpeekobnhjjdofggfgjlcehhmanlj
+ "f395f05735f18cd7b7b630f8fa224a97d7371cf472ed71cb70c1d809a4d673b5",
+ // Magic Eden: mkpegjkblkkefacfnmkajcjmabijhclg
+ "4c34d6534d8712bb7d4e6046b33e573a3ef5419aaa117189a296de5a7fe71141",
+ // Martian: efbglgofoippbgcjepnhiblaibcnclgk
+ "da7333b15f7b18e139281d6a78f0d5c10003cfcaa7fe8cd10794d4edc69d9084",
+ // MathWallet: afbcbjpbpfadlkmhmclhkeeodmamcflc
+ "31497d3c5083cb3949f40f795e38268e4ec3a9d2999586c5abdafdfaeb36665a",
+ // MathWallet, from Edge Add-ons: dfeccadlilpndjjohbjdblepmjeahlmm
+ "4467198c8ffb192bb5782e730d8db7d312b923e5c70af089a3ed0e551897de9e",
+ // MetaMask: nkbihfbeogaeaoehlefnkodbefgpgknn
+ "236d1c2349dcbf080a5ee149888b545ecad6b43dc560360f06be2aac4069e5ce",
+ // MetaMask Flask: ljfoeinjpaedjfecbmggjgodbgkmjkjk
+ "9097564df3d3cbccb27493dcab7e48fa1d5b3c72c1a3d6d7a2f7d871250724ae",
+ // MetaMask, from Edge Add-ons: ejbalbakoplchlghecdalmeeeajnimhm
+ "6c77888d7a8eb5be815c4b44b8ad07bacd353042f92f4a9c5c53d8a3ac305650",
+ // My Wallet, formerly MyTonWallet: fldfpgipfncgndfolcbkdeeknbbbnhcc
+ "6f1d8db7106ded0b70b87c077e37186037c5d6aebfe3d5ff464fb173f869514f",
+ // Nami: lpfcbjknijpeeillifnkikgncikgfhdo
+ "98de2c74f85de4a080048b455947cbb19abb654af2d89a45024adbf5ac8d15a6",
+ // Nightly: fiikommddbeccaoicoejoniammnalkfa
+ "a1ecf6753a231f0b9f2e671dd3ff2cb3ca76f23338c9813b27250e58156f3f20",
+ // OKX Wallet: mcohilncbfahbmgdjkbpemcciiolgcge
+ "7ed4974fa52e80026ebdf8d199060189191be1c27191afd975f8d4c6cb25f9e4",
+ // OKX Wallet, from Edge Add-ons: pbpjkcldjiffchgbbndmhojiacbgflha
+ "f6aea63722848fd2e3c87d0a2c57a52087ce72ba7364fa88144e3c38532b78e9",
+ // OneKey: jnmbobjmhlngoefaiojfljckilhhlhcj
+ "473b973c463c34348e2fa430e6556d77f5429d51b5eb451ba2e7da10cca77a84",
+ // OneKey, from Edge Add-ons: obffkkagpmohennipjokmpllocnlndac
+ "939f0a09e05d3a6687c10e5a85e131a646f7d15fff11e5d3869fa243a9d3eab9",
+ // OpenMask: penjlddjkjgpnkllboccdgccekpkcbin
+ "b1bb27f08f466820bf5803c00876c29e304cbb07df784be0a69e14246a3585f2",
+ // Petra: ejjladinnckdgjemekebdpeokbikhfci
+ "3c5fc2147981d472e621602caaa6fa2afc8150b941d4444d033598862cf48011",
+ // Phantom: bfnaelmomeimhlpmgjnjophhpkkoljpa
+ "457bbba6087abd61ed26c6db18f9258fdcd508b3ad34481afef7a7d49ae44ea7",
+ // Phantom, from Edge Add-ons, withdrawn: bmnkhaipfhdepcgopndfebkamdikcjhi
+ "98af4c28e569362c23a1a0cf34dc35e137486ca3564b5279be53e914b99c8c26",
+ // polkadot{.js}: mopnmbcafieddcagagdcbnhejhlodfdd
+ "37c3731cf4d0ed4b632b1bb5219ce30043b49ae3f1c3abd3e39248d7616705ca",
+ // Pontem: phkbamefinggmakgklpkljjmgibohnba
+ "0194c07603a6c3bdc4ae274330384ffd7d5a8a5428b9ad1a4d36739d3a097435",
+ // Rabby: acmacodkjbdgmoleebolmdjonilkdbch
+ "fdbcc88c100d3fd0baf5888d6e69e9f60abb46ab9634d6b18682c1ca575654fa",
+ // Rainbow: opfgelmcmbiajamepnmloijbpoleiama
+ "58e9b16463ebc725fa06927bdbebe3a8aec5a87572c9105490688b8c9ed97e1d",
+ // Ready, formerly Argent X: dlcobpjiigpikoobohmabehhmhfoodbb
+ "c830d8ad731267cbe6e3fdd4dc718d18a8c6d03ba415c9ee60ce93e53b0ba264",
+ // Ronin: fnjhmkhhmkbjkkabndcnnogagogbneec
+ "82ea7fe5283acdb80b87e3346d7e39e1b06e0d0a61dcf261cdb37d670f9b4847",
+ // Ronin, from Edge Add-ons: kjmoohlgokccodicjjfebfomlbljgfhk
+ "81d1be83e1e517a7ddb28d2eaf03456f3917901aaea7de55fd0cb0f988f7c75b",
+ // SafePal: lgmpcpglpngdoalbgeoldeajfclnhafa
+ "cfadd0fb037e1a70ec5d887e8b55b8971ad79fafc9c69c51c189fd18eacd5c5c",
+ // SafePal, from Edge Add-ons: apenkfbbpmhihehmihndmmcdanacolnh
+ "7157f98ef4dcc2264bf4b1603893684b12094a50c23a7d28cbe3b816d0668a28",
+ // SecondFi, formerly Yoroi: ffnbelfdoeiohenkjibnmadjiehjhajb
+ "641b30f55c707fcd89fc18c4d8c8560a7f42386e639d4ea7f0fb0b8e21373c1f",
+ // SecondFi, from Edge Add-ons: akoiaibnepcedcplijmiamnaigbepmcb
+ "939fb6f2a67d5b988e7378988363ecd7a394fceec31056ed8151054bc981ea57",
+ // Slush, formerly Sui Wallet: opcgpfmipidbgpenhmajoajpbobppdil
+ "af9d4616d22d91d651492edbc0f3be6ad6e2c43b05dc62bcdb0384aad93c4ab8",
+ // Solflare: bhhhlbepdkbapadjdnnojkbgioiodbic
+ "e5e3d9c385dd6a06b1daa03fb0ca2f26d6bacd7179ff9c36e1309ce730b86477",
+ // Station: aiifbnbfobpmeekipheeijimdpnlpgpp
+ "b552892aa933e42bc5371c5aa4b4daded27936c043fcbba3b7e928c67cee7d8e",
+ // SubWallet: onhogfjeacnfoofkfgppdlbmlmnplgbn
+ "c5ba81d486db388298fc6df0f4610f26d7af75392a56b183e0f7ae3c7413fc67",
+ // Taho: eajafomhmkipbjmfmhebemolkcicgfmd
+ "a3a0c5cd9e728c950fbd2c704ed2f8bb7638c2fb88d574be4cd8b8b7741ee0eb",
+ // Talisman: fijngjgcjhjmmpcmkeiomlglpeiijkld
+ "24f4a0a541490aaefc23d8b667d9db8ad451cbd7dcbba00f2527b60a2613560c",
+ // Temple: ookjlbkiijinhpmnjffcofjonbfbgaoc
+ "7291b6bc431a43f4ee38b23cde4e074cd3784a9764e2318c51b20c4c53d75063",
+ // TokenPocket: mfgccjchihfkkindfppnaooecgfneiii
+ "5a994c3dcab5c805825cf0084b24a74cc785f7ab88fac9ff026cb4510bd3a1b1",
+ // Tonkeeper: omaabbefbmiijedngplfjmnooppbclkk
+ "8484221dfd00dfb0a5dccb0e035d5097e2752c4ff5ea1610e85313fb95b0b771",
+ // TronLink: ibnejdfjmmkpcnlpebklmnkoeoihofec
+ "0968fd7a8577f69abf6eff96cf02bd1652952230a0a883efc8b2b70af6d454fe",
+ // TronLink, from Edge Add-ons: aheklkkgnmlknpgogcnhkbenfllfcfjb
+ "fcd32be9e1fabba31a3d9f489750aab47fc3b19d47771039dad8cf3f395d5f97",
+ // Trust Wallet: egjidjbpglichdcondbcbdnbeeppgdph
+ "0c95ff4a29972e157119e75189d502b410884f50cbe6df1acb512ccd7b60ac9c",
+ // Trust Wallet, from Edge Add-ons, withdrawn: cmoejppohfldenjbieahmemfkglcenlf
+ "9f54a78f6c91801cc533e8e1969dd930d35dfb61ce406137b969f3a2fda1c4b7",
+ // UniSat: ppbibelpcjmhbdihakflkdcoccbgbkpo
+ "655aca5197f03a5672bd0f98b32b516e8e500a184890fbfea6cb59dfa9d92d82",
+ // Uniswap: nnpmfplkfogfpmcngplhnbdnnilmcdcg
+ "bd6fa2745786fd6b6a22c2bf931b8ccf6f9d0b0bad1b55d2b963620d4fa8387e",
+ // Xverse: idnnbdplmphpflfnlkomgpfbpcgelopg
+ "fc2500db4fed3fdcd31968aecbde501f8909abca65f9fcd2374f86e082778b53",
+ // Zerion: klghhnkeealcohjjanjjdaeeggmfmlpl
+ "e7f95a0be1ba297d9565edd2cc0558efd46857816cf6bef452ca021898c3357c",
+ ]
+
+ /// The fingerprints of wallet add-ons on addons.mozilla.org, of their IDs in lowercase. Firefox installs an
+ /// add-on as `extensions/<ID>.xpi` in the profile, and removes its storage when the add-on is removed.
+ public static let walletAddOns: Set<String> = [
+ "f758c0ade84f7a93d09cbe7c6d9c15532bc336d3cf15d52c56563f081c97228d",
+ // Ambire: [email protected]
+ "306d0fc0eeeb74b3d040c32d22fee199905e5df19d60b473d262e41e58ce451e",
+ // Braavos: {a0c6ccfd-26a3-4df4-9729-aa036070ad29}
+ "d536965e0833bc553d1bc1058a5b94583d8747d334c16888a5453938f2ae3693",
+ // Enkrypt: {21a9e8ea-7aa4-4aae-923c-ec8211f2779c}
+ "0332d3649de49795f7074fa19aeda4f8d8f677adf66c736163b757894a3eb544",
+ // Keplr: [email protected]
+ "6b0f6babbb81790dd97b8ddff12ab787d8748b269a8a635b09167b65b196f565",
+ "a4c5e84beddb359fae28624885da033ecf192535d3616625cec897b65421faa2",
+ // MetaMask: [email protected]
+ "ce84733ead38daa7c822e11172031b90a8c1afa029e97b120202ff9d294a1c1f",
+ // MetaMask Flask: [email protected]
+ "c1376eab47cb9e03a886e6c12b09f027eb8a78fb84c073a97c7ea85e92d5f0c6",
+ // My Wallet, formerly MyTonWallet: {98fcdaee-2b58-4f71-8a3c-f0c66f24dede}
+ "d75f165247ed9fee1470778d5cbd5c3a4d0f4c68c5bc17a52a71bf2b6267e32f",
+ // Nightly: {76026700-1d2e-4c46-8454-198e27682104}
+ "16b79069b9be67309856bc41364bf6fdca535ef9783fa01217fe835fd730169c",
+ // Phantom: {7c42eea1-b3e4-4be4-a56f-82a5852b12dc}
+ "268a02ec6c026f9119c539be095d9cf28afb4cd8e2cbaf11da769ab281b21071",
+ // polkadot{.js}: {7e3ce1f0-15fb-4fb1-99c6-25774749ec6d}
+ "4499712a3dc85e4906da18bfb25acec2a50df42bdf4d109f5d927d49938de256",
+ // Rainbow: [email protected]
+ "1802cfc84fa2aedd44ac7efbdfae6a0a5d128d149153fc01b2c031f3ceefe7be",
+ // Ready, formerly Argent: {51e0c76c-7dbc-41ba-a45d-c579be84301b}
+ "bc41d70d731d4e0335e6c577f30468c841fadf883d12cd64cda6e4d0847c75f3",
+ // Ronin: [email protected]
+ "2907115e80c4db9c3e6258873e812aa9b2c1f5141a22d8ed10751f3cb0dd3656",
+ // Solflare: {6d72262a-b243-4dc6-8f4f-be96c74e0a86}
+ "6859225ddefd61629e37a034f1f27efd97a5971b1a69cd53879493f3ef63d745",
+ // SubWallet: {8a3a53f5-7490-46d7-b91d-f8549bb8df05}
+ "ce5b6d31d558ea31a6899edc5205708367302288afc0993e54b61d56da9e8c75",
+ // Talisman: {f5727e03-b26c-41e0-95dd-7e315ff16410}
+ "8201dbc6334f5e9831ac8f27475041288427265d18d59671949d31f212ee9d32",
+ // Tonkeeper: [email protected]
+ "2316b22a464674a9a9c523d721924a20ae69f1af6c837bcae2d2e0eac31179b3",
+ // Yoroi: {530f7c6c-6077-4703-8f71-cb368c663e35}
+ "1cc2bbde8109ee93a06fb52a2364ef92ca454a2fde9999a78b965343d5fec627",
+ // Zerion: [email protected]
+ "f6c94dd6e7008bdd134f3df52a54a7a5d31f1a1ee2940dbeadfad54aa6f9f1dc",
+ ]
+
+ /// The SHA-256 of `id`, in lowercase hex, which is how the lists above hold each ID.
+ static func fingerprint(_ id: String) -> String {
+ SHA256.hash(data: Data(id.utf8)).map { String(format: "%02x", $0) }.joined()
+ }
+
+ /// True for a path at or inside a wallet extension's storage: `Local Extension Settings/<ID>` or an IndexedDB
+ /// store of `chrome-extension_<ID>_0` in a Chromium profile, or `extensions/<ID>.xpi` in a Firefox profile.
+ /// Expects the path's names in lowercase.
+ static func isInsideAWalletExtension(_ names: [String]) -> Bool {
+ zip(names, names.dropFirst()).contains { folder, name in isAWalletsStorage(name, in: folder) }
+ }
+
+ /// True for a folder that is, or holds a level or two down, a browser profile with a wallet in it, which is
+ /// as deep as a browser keeps a profile (`Google/Chrome/Default`, `Firefox/Profiles/<name>`), and for a
+ /// profile's `Local Extension Settings`, `IndexedDB`, or `extensions` holding a wallet's storage. Inside such
+ /// a profile it is also true for what a wallet can share with other extensions: `Local Storage`, Firefox's
+ /// `storage`, and `Preferences`, where Brave keeps its own wallet. It reads the disk, so it needs the path as
+ /// spelled on disk.
+ public static func holdsABrowserWallet(_ path: String) -> Bool {
+ let components = PathComponents.of(path)
+ if let profile = profile(sharedBy: components), isAProfileWithAWallet(profile) { return true }
+ if isAProfileWithAWallet(path) { return true }
+
+ let folder = components.last?.lowercased() ?? ""
+ let children = (try? FileManager.default.contentsOfDirectory(atPath: path)) ?? []
+ return children.contains { child in
+ let inside = path + "/" + child
+ if isAWalletsStorage(child.lowercased(), in: folder) || isAProfileWithAWallet(inside) { return true }
+ let deeper = (try? FileManager.default.contentsOfDirectory(atPath: inside)) ?? []
+ return deeper.contains { isAProfileWithAWallet(inside + "/" + $0) }
+ }
+ }
+
+ /// True for `name`, inside a folder called `folder`, when it is a wallet extension's storage. Both lowercase.
+ private static func isAWalletsStorage(_ name: String, in folder: String) -> Bool {
+ switch folder {
+ case "local extension settings":
+ return name.count == 32 && walletExtensions.contains(fingerprint(name))
+ case "indexeddb":
+ // `chrome-extension_<ID>_0.indexeddb.leveldb` and `.indexeddb.blob`, or the folder of its own that the
+ // SQLite store gives each origin, `chrome-extension_<ID>_0`.
+ guard name.hasPrefix("chrome-extension_") else { return false }
+ let rest = name.dropFirst("chrome-extension_".count)
+ let port = rest.dropFirst(32)
+ guard port == "_0" || port.hasPrefix("_0.indexeddb.") else { return false }
+ return walletExtensions.contains(fingerprint(String(rest.prefix(32))))
+ case "extensions":
+ return name.hasSuffix(".xpi") && walletAddOns.contains(fingerprint(String(name.dropLast(".xpi".count))))
+ default:
+ return false
+ }
+ }
+
+ /// 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`.
+ private static func isAProfileWithAWallet(_ profile: String) -> Bool {
+ for folder in ["Local Extension Settings", "IndexedDB", "extensions"] {
+ let names = (try? FileManager.default.contentsOfDirectory(atPath: profile + "/" + folder)) ?? []
+ if names.contains(where: { isAWalletsStorage($0.lowercased(), in: folder.lowercased()) }) { return true }
+ }
+ return holdsBravesWallet(profile + "/Preferences")
+ }
+
+ /// True when a profile's `Preferences` carries Brave's wallet, whose encrypted recovery phrase Brave keeps there
+ /// as `brave.wallet.encrypted_mnemonic`. A file too big or not allowed to be read is not known to be without
+ /// one, so it counts as one.
+ private static func holdsBravesWallet(_ file: String) -> Bool {
+ var info = stat()
+ guard lstat(file, &info) == 0, info.st_mode & S_IFMT == S_IFREG else { return false }
+ guard info.st_size <= 64 << 20, let contents = FileManager.default.contents(atPath: file) else { return true }
+ return contents.range(of: Data(#""encrypted_mnemonic""#.utf8)) != nil
+ }
+
+ /// The profile a path belongs to when the path is a part of it that every extension shares: at or inside
+ /// `Local Storage` or Firefox's `storage`, or its `Preferences` file.
+ private static func profile(sharedBy components: [String]) -> String? {
+ let names = components.map { $0.lowercased() }
+ let shared = names.lastIndex { $0 == "local storage" || $0 == "storage" }
+ ?? (names.last == "preferences" ? names.count - 1 : nil)
+ guard let shared, shared > 0 else { return nil }
+ return "/" + components[..<shared].joined(separator: "/")
+ }
+}
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift b/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift
index 7ad34d47..03acd1ec 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift
@@ -122,7 +122,8 @@ public struct PrivilegedPathPolicy: Sendable {
!ProtectedData.holds(resolved, home: homeDirectory),
!ProtectedData.holdsAContainersDocuments(resolved),
!ProtectedData.holdsWorkKeptInACache(resolved),
- !ProtectedData.holdsALibrary(resolved)
+ !ProtectedData.holdsALibrary(resolved),
+ !ProtectedData.holdsABrowserWallet(resolved)
else { return .failure(.irreplaceable) }
guard let location = locations.first(where: { PathComponents.isPath(resolved, inside: $0) }) else {
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
index 07c65d9c..b3bfbd4a 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
@@ -326,15 +326,16 @@ public enum ProtectedData: Sendable {
return [path]
}
- /// True for a path at or inside anything protected here: the home and system folders, the keys, a media
- /// library, a global preferences file, or one of Apple's group containers. Running as root, the helper
- /// can see every account on the Mac, so a home folder is any folder directly inside `/Users`, as well as
- /// the one given.
+ /// True for a path at or inside anything protected here: the home and system folders, the keys, a wallet
+ /// extension's storage, a media library, a global preferences file, or one of Apple's group containers.
+ /// Running as root, the helper can see every account on the Mac, so a home folder is any folder directly
+ /// inside `/Users`, as well as the one given.
public static func refuses(_ path: String, home: String) -> Bool {
spellings(of: path).contains { spelling in
let names = PathComponents.of(spelling)
if names.contains(where: { name in extensions.contains { name.hasSuffix("." + $0) } }) { return true }
if isGlobalPreferences(spelling) || isInAnApplesGroupContainer(spelling) { return true }
+ if isInsideAWalletExtension(names) { return true }
for home in homes(of: spelling, given: home) where trees(under: home).contains(where: names.starts(with:)) {
return true
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift
new file mode 100644
index 00000000..c796a9b0
--- /dev/null
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift
@@ -0,0 +1,140 @@
+import Foundation
+@testable import PeelCore
+@testable import PeelPrivileged
+import Testing
+
+/// A wallet extension keeps its vault inside a browser profile. The vault, the profile, and every folder around it
+/// are refused, while the rest of what a browser keeps can still go.
+struct BrowserWalletTests {
+ private let metaMask = WalletIDs.metaMask
+ /// An ad blocker, which holds no wallet.
+ private let adBlocker = "cjpalhdlnbpafiamejdnhcphjbkeiagm"
+
+ private func guardian(in directory: borrowing TemporaryDirectory) -> RemovalGuard {
+ RemovalGuard(environment: SearchEnvironment(
+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),
+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)
+ ))
+ }
+
+ private func refused(_ paths: [String], allowed: [String], in directory: borrowing TemporaryDirectory) {
+ let guardian = guardian(in: directory)
+ for path in paths {
+ #expect(!guardian.allowsRemoval(of: directory.url.appending(path: path)), "\(path) may be removed")
+ }
+ for path in allowed {
+ #expect(guardian.allowsRemoval(of: directory.url.appending(path: path)), "\(path) is refused")
+ }
+ }
+
+ /// Chrome keeps a profile two levels inside its maker's folder, and an extension's `storage.local` in the
+ /// profile's `Local Extension Settings`. `Local Storage` is shared by every extension, so it stays too.
+ @Test func aChromiumProfileWithAWalletStaysWithEveryFolderAroundIt() throws {
+ let directory = try TemporaryDirectory()
+ let chrome = "home/Library/Application Support/Google/Chrome"
+ try directory.file("\(chrome)/Local State")
+ try directory.file("\(chrome)/Default/Local Extension Settings/\(metaMask)/000003.log")
+ try directory.file("\(chrome)/Default/Local Storage/leveldb/000005.ldb")
+ try directory.file("\(chrome)/Default/Cache/Cache_Data/data_0", bytes: 4_096)
+ try directory.file("\(chrome)/Profile 1/Local Extension Settings/\(adBlocker)/000003.log")
+ try directory.file("\(chrome)/Profile 1/Local Storage/leveldb/000005.ldb")
+
+ refused([
+ "home/Library/Application Support/Google",
+ chrome,
+ "\(chrome)/Default",
+ "\(chrome)/Default/Local Extension Settings",
+ "\(chrome)/Default/Local Extension Settings/\(metaMask)",
+ "\(chrome)/Default/Local Extension Settings/\(metaMask)/000003.log",
+ "\(chrome)/Default/Local Storage",
+ "\(chrome)/Default/Local Storage/leveldb/000005.ldb",
+ ], allowed: [
+ "\(chrome)/Default/Cache",
+ "\(chrome)/Profile 1",
+ "\(chrome)/Profile 1/Local Storage",
+ ], in: directory)
+ }
+
+ /// A wallet can keep its vault in IndexedDB instead, under any of the names Chromium gives an origin's store.
+ @Test func everyIndexedDBStoreOfAWalletCounts() throws {
+ let profile = "home/Library/Application Support/BraveSoftware/Brave-Browser/Default"
+ for store in ["\(metaMask)_0.indexeddb.leveldb", "\(metaMask)_0.indexeddb.blob", "\(metaMask)_0"] {
+ let directory = try TemporaryDirectory()
+ try directory.file("\(profile)/IndexedDB/chrome-extension_\(store)/000003.log")
+ refused([
+ "home/Library/Application Support/BraveSoftware",
+ "\(profile)/IndexedDB/chrome-extension_\(store)",
+ ], allowed: [], in: directory)
+ }
+
+ // Another extension's store, or a name that only begins like a wallet's, holds no wallet.
+ let directory = try TemporaryDirectory()
+ try directory.file("\(profile)/IndexedDB/chrome-extension_\(adBlocker)_0.indexeddb.leveldb/000003.log")
+ try directory.file("\(profile)/IndexedDB/chrome-extension_\(metaMask)_1.indexeddb.leveldb/000003.log")
+ refused([], allowed: ["home/Library/Application Support/BraveSoftware"], in: directory)
+ }
+
+ /// Firefox installs an add-on as `extensions/<ID>.xpi`, and keeps its data in the profile's `storage` under
+ /// a name only the profile's settings connect to the add-on.
+ @Test func aFirefoxProfileWithAWalletAddOnStays() throws {
+ let directory = try TemporaryDirectory()
+ let profiles = "home/Library/Application Support/Firefox/Profiles"
+ try directory.file("\(profiles)/a1b2.default-release/extensions/\(WalletIDs.metaMaskForFirefox).xpi")
+ try directory.file("\(profiles)/a1b2.default-release/storage/default/moz-extension+++5f1c^userContextId=4294967295/idb/1.sqlite")
+ try directory.file("\(profiles)/c3d4.work/extensions/[email protected]")
+ try directory.file("\(profiles)/c3d4.work/storage/default/moz-extension+++9e2a/idb/1.sqlite")
+
+ refused([
+ "home/Library/Application Support/Firefox",
+ profiles,
+ "\(profiles)/a1b2.default-release",
+ "\(profiles)/a1b2.default-release/extensions",
+ "\(profiles)/a1b2.default-release/extensions/\(WalletIDs.metaMaskForFirefox).xpi",
+ "\(profiles)/a1b2.default-release/storage",
+ "\(profiles)/a1b2.default-release/storage/default",
+ ], allowed: [
+ "\(profiles)/c3d4.work",
+ "\(profiles)/c3d4.work/storage",
+ ], in: directory)
+ }
+
+ /// Brave keeps its own wallet's encrypted recovery phrase in the profile's `Preferences`.
+ @Test func bravesOwnWalletKeepsItsProfile() throws {
+ let directory = try TemporaryDirectory()
+ let brave = "home/Library/Application Support/BraveSoftware/Brave-Browser"
+ try directory.file("\(brave)/Default/Preferences", contents: Data(#"{"brave":{"wallet":{"encrypted_mnemonic":"c2VjcmV0"}}}"#.utf8))
+ try directory.file("\(brave)/Profile 1/Preferences", contents: Data(#"{"brave":{"new_tab_page":{}}}"#.utf8))
+
+ refused([brave, "\(brave)/Default", "\(brave)/Default/Preferences"], allowed: ["\(brave)/Profile 1"], in: directory)
+ }
+
+ /// Opera keeps its first profile in its folder itself, and Arc its profiles in `User Data`.
+ @Test func findsAProfileWhereverABrowserKeepsIt() throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Application Support/com.operasoftware.Opera/Local Extension Settings/\(metaMask)/000003.log")
+ try directory.file("home/Library/Application Support/Arc/User Data/Default/Local Extension Settings/\(metaMask)/000003.log")
+
+ refused([
+ "home/Library/Application Support/com.operasoftware.Opera",
+ "home/Library/Application Support/Arc",
+ ], allowed: [], in: directory)
+ }
+
+ /// Every fingerprint is the SHA-256 of the ID in the comment above it, and no entry is missing one. A Chromium
+ /// ID is 32 letters from a to p, which reading an IndexedDB store's name relies on, and an add-on's ID is kept in
+ /// lowercase, as the lookup compares it.
+ @Test func everyFingerprintIsTheIDAboveIt() throws {
+ let extensions = try WalletIDs.entries(of: "walletExtensions")
+ let addOns = try WalletIDs.entries(of: "walletAddOns")
+
+ #expect(extensions.count == ProtectedData.walletExtensions.count)
+ #expect(Set(extensions.map(\.fingerprint)) == ProtectedData.walletExtensions)
+ #expect(addOns.count == ProtectedData.walletAddOns.count)
+ #expect(Set(addOns.map(\.fingerprint)) == ProtectedData.walletAddOns)
+ for entry in extensions + addOns {
+ #expect(ProtectedData.fingerprint(entry.id) == entry.fingerprint, "\(entry.name)")
+ }
+ #expect(extensions.allSatisfy { $0.id.count == 32 && $0.id.allSatisfy { ("a"..."p").contains($0) } })
+ #expect(addOns.allSatisfy { $0.id == $0.id.lowercased() && !$0.id.hasSuffix(".xpi") })
+ }
+}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 8ec83e5e..9e7d34e5 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -561,6 +561,18 @@ struct LeftoverScannerTests {
#expect(folder.match.heldBack?.cannotBeMoved == true)
}
+ /// A browser's folder that holds a profile with a wallet extension cannot be selected either.
+ @Test func aBrowsersFolderHoldingAWalletCannotBeSelected() async throws {
+ let directory = try TemporaryDirectory()
+ let opera = InstalledApp(url: URL(filePath: "/Applications/Opera.app"), bundleIdentifier: "com.operasoftware.Opera", name: "Opera")
+ try directory.file("home/Library/Application Support/com.operasoftware.Opera/Local Extension Settings/\(WalletIDs.metaMask)/000003.log")
+
+ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(opera, installedApps: [opera])
+ let folder = try #require(scan.leftovers.first { $0.url.lastPathComponent == "com.operasoftware.Opera" })
+
+ #expect(folder.match.heldBack == .holdsKeys)
+ }
+
/// Plug-ins are found in the user's Library and the system's, including inside a vendor's own folder.
@Test func findsThePlugInsAnAppInstalled() async throws {
let directory = try TemporaryDirectory()
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index c19846fd..958ad600 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -285,6 +285,16 @@ struct OrphanScannerTests {
#expect(items.first?.leftAlone == .holdsKeys)
}
+ /// A browser that is gone can leave its profile behind, and a wallet extension's vault in it.
+ @Test func anOrphanedBrowserFolderHoldingAWalletIsLeftAlone() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Application Support/com.operasoftware.Opera/Local Extension Settings/\(WalletIDs.metaMask)/000003.log")
+
+ let items = await scanner(in: directory).scan(installedApps: installed).groups.flatMap(\.items)
+
+ #expect(items.map(\.leftAlone) == [.holdsKeys])
+ }
+
/// The apps macOS ships claim their folders like any other app, and none of them is in the list Peel scans.
@Test func ignoresGroupsDeclaredBySystemApps() async throws {
let directory = try TemporaryDirectory()
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
index c1a33f91..7d97f4ec 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
@@ -45,6 +45,21 @@ struct PrivilegedPathPolicyTests {
}
}
+ /// A browser profile with a wallet extension's vault stays, and so does every folder around it, while the rest
+ /// of the profile can still go.
+ @Test func refusesAFolderHoldingABrowserWallet() throws {
+ let directory = try TemporaryDirectory()
+ let policy = try policy(in: directory)
+ let profile = "root/Library/Caches/Vendor/Browser/Default"
+ try directory.file("\(profile)/Local Extension Settings/\(WalletIDs.metaMask)/000003.log")
+ try directory.file("\(profile)/Cache/data_0")
+
+ #expect(policy.refusal(of: path("root/Library/Caches/Vendor", in: directory)) == .irreplaceable)
+ #expect(policy.refusal(of: path(profile, in: directory)) == .irreplaceable)
+ #expect(policy.refusal(of: path("\(profile)/Local Extension Settings/\(WalletIDs.metaMask)", in: directory)) == .irreplaceable)
+ #expect(policy.refusal(of: path("\(profile)/Cache", in: directory)) == nil)
+ }
+
/// Peel calls `refusal(of:)` before it offers the helper anything, so it must give the same answer as `open`.
@Test func saysBeforeOpeningAnythingWhatOpeningWouldRefuse() throws {
let directory = try TemporaryDirectory()
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/WalletIDs.swift b/Packages/PeelCore/Tests/PeelCoreTests/WalletIDs.swift
new file mode 100644
index 00000000..b480e668
--- /dev/null
+++ b/Packages/PeelCore/Tests/PeelCoreTests/WalletIDs.swift
@@ -0,0 +1,51 @@
+import Foundation
+import Testing
+
+/// The wallet IDs that `BrowserWallets.swift` names in its comments, read from the source while a test runs. A test
+/// binary that carried them as text would be taken for a program that steals wallets: XProtect, the malware scanner
+/// built into macOS, moves such a binary to the Trash.
+enum WalletIDs {
+ struct Entry {
+ let name: String
+ let id: String
+ let fingerprint: String
+ }
+
+ static let source = URL(filePath: #filePath)
+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ .appending(path: "Sources/PeelPrivileged/BrowserWallets.swift")
+
+ /// MetaMask's ID in the Chrome Web Store, and its add-on ID in Firefox.
+ static var metaMask: String { id(of: "MetaMask", in: "walletExtensions") }
+ static var metaMaskForFirefox: String { id(of: "MetaMask", in: "walletAddOns") }
+
+ /// The entries of the list declared as `list`: each fingerprint, with the name and the ID in the comment above.
+ static func entries(of list: String) throws -> [Entry] {
+ let text = try String(contentsOf: source, encoding: .utf8)
+ guard
+ let start = text.range(of: "static let \(list): Set<String> = ["),
+ let end = text.range(of: "\n ]", range: start.upperBound..<text.endIndex)
+ else { return [] }
+
+ var entries: [Entry] = []
+ var named: (name: String, id: String)?
+ for line in text[start.upperBound..<end.lowerBound].split(separator: "\n") {
+ let line = line.trimmingCharacters(in: .whitespaces)
+ if line.hasPrefix("// "), let colon = line.range(of: ": ", options: .backwards) {
+ named = (String(line[line.index(line.startIndex, offsetBy: 3)..<colon.lowerBound]), String(line[colon.upperBound...]))
+ } else if line.hasPrefix("\""), let wallet = named {
+ entries.append(Entry(name: wallet.name, id: wallet.id, fingerprint: String(line.dropFirst().prefix(64))))
+ named = nil
+ }
+ }
+ return entries
+ }
+
+ private static func id(of name: String, in list: String) -> String {
+ guard let entry = (try? entries(of: list))?.first(where: { $0.name == name }) else {
+ Issue.record("BrowserWallets.swift names no \(name) in \(list)")
+ return ""
+ }
+ return entry.id
+ }
+}
diff --git a/README.md b/README.md
index d2bef877..f490966e 100644
--- a/README.md
+++ b/README.md
@@ -152,9 +152,10 @@ A cleaner should never cost you something you wanted. Peel is built around that.
- **Protected places stay protected.** Peel refuses to move iCloud Drive, keychains, your SSH and signing keys, the
keys of crypto wallets, Mail, Messages, Safari, Contacts, Calendars, Notes, photo and music libraries, iPhone and
iPad backups, and the Desktop, Documents, and Downloads folders themselves. No selection can override it.
-- **Crypto wallets are never selected for you.** Beyond the places wallets keep their keys, a folder an uninstall
- or Orphaned Files finds a wallet or a signing key in is shown with that reason and moves only if you select it
- yourself. [SAFETY.md](SAFETY.md#crypto-wallets) says how Peel knows one.
+- **Crypto wallets are never selected for you.** Beyond the places wallets keep their keys, a browser profile with
+ a wallet extension such as MetaMask stays where it is, so uninstalling a browser never takes a wallet with it.
+ A folder an uninstall or Orphaned Files finds a wallet or a signing key in is shown with that reason and moves
+ only if you select it yourself. [SAFETY.md](SAFETY.md#crypto-wallets) says how Peel knows one.
- **Checked again at the last moment.** Peel looks at each item once more right before it moves, so something
swapped in the meantime stays where it is.
- **Nothing shared, nothing unknown.** A file another app also uses is never selected for you. A folder Peel
diff --git a/SAFETY.md b/SAFETY.md
index 60233c03..21dcd968 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -48,7 +48,9 @@ moved whole. Anything System Integrity Protection guards, which macOS marks as r
Everywhere on the Mac: `/Library/Keychains`, and any `.photoslibrary`, `.photolibrary`, `.migratedphotolibrary`,
`.musiclibrary`, `.tvlibrary`, `.imovielibrary`, `.fcpbundle`, or `.aplibrary`: somebody's whole photo, music, or
video collection. A folder with one of them a level or two inside stays too, since moving the folder would take the
-library along, and the row says so instead of failing when you press the button.
+library along, and the row says so instead of failing when you press the button. A browser profile with a
+wallet in it stays the same way, and so does a folder that holds one a level or two down: see
+[Crypto wallets](#crypto-wallets).
Also refused: work that an app keeps inside a *cache* folder and nowhere else. A JetBrains IDE and Android
Studio record your unsaved edits in `LocalHistory`, beside their caches, and Deno keeps `localStorage` and its
@@ -155,12 +157,18 @@ snapshots are explained, never deleted.
## Crypto wallets
-A wallet's keys can be the only way to what they hold, so Peel keeps them in three ways.
+A wallet's keys can be the only way to what they hold, so Peel keeps them in four ways.
- **Where wallets keep their keys is never removed.** The 58 places in the table at the top of this page, each
read from the wallet's own documentation or source, are refused outright by the app, the `peel` tool, and the
helper, and so is any folder that holds one. What comes back on its own beside a key, such as a downloaded
blockchain, can still go.
+- **A browser profile with a wallet stays.** A wallet extension such as MetaMask or Phantom keeps its vault in the
+ browser's profile, beside `Local Storage`, which every extension shares. So a profile that holds one of the
+ wallet extensions Peel knows (those of more than 60 wallets, for Chrome, Brave, Edge, Arc, Opera, Vivaldi, and
+ Firefox) 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.
- **A wallet found anywhere else is never selected for you.** When an uninstall or Orphaned Files measures a
folder, 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`