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.

Refuse a folder Peel can't see all through

Țugui Dragoș7b2b6ce82329
diff --git a/AGENTS.md b/AGENTS.md
index b44b7fec..3ce483d0 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -140,7 +140,9 @@ checked by hand. If a change makes one of them fail, the rule is right and the c
- **What can't be read is unknown, never empty or zero.** A folder macOS won't let Peel read, or one that doesn't
answer in time, has no size (`FileSize` answers nil) and is never taken for empty. Only a name that isn't there
(`lstat` answering `ENOENT`) makes one of Peel's own files empty; anything else reads as unreadable, and while
- History or the exclusions can't be read, nothing moves.
+ History or the exclusions can't be read, nothing moves. The guard's rules that look a level or two inside a folder
+ answer `ProtectedData.Finding`, and a folder with one inside they couldn't list is refused, unless only the helper
+ can move it, which looks inside as root.
## The privileged helper
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 039e5d5a..1db932f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -231,6 +231,9 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
- Every folder on the way to a place Peel searches, such as `~/Library/Audio`, is refused whole, by the app and by
the helper, so what is inside it can't go as part of its folder. A browser's own data folder still goes with the
browser.
+- A folder with a folder inside that macOS won't let Peel list is refused, by the app and by the helper, since a photo
+ library, a browser's wallet, or work an app keeps only in a cache may be in there, and its row says so. One only an
+ administrator can move is left to the helper, which looks inside as root.
## 1.1.0 (2026-10-14)
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 76929011..abb985c7 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -70185,6 +70185,112 @@
}
}
},
+ "Left alone: macOS wouldn’t let Peel look inside to make sure nothing Peel protects, such as a library or a wallet, is there. If Peel doesn’t have Full Disk Access yet, giving it in System Settings may let it see." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nedotčeno: systém macOS nedovolil Peelu nahlédnout dovnitř a ověřit, že tam není nic, co Peel chrání, například knihovna nebo peněženka. Pokud Peel ještě nemá plný přístup k disku, jeho udělení v Nastavení systému mu to může umožnit."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Unangetastet: macOS hat Peel nicht hineinsehen lassen, daher kann Peel nicht sicherstellen, dass darin nichts liegt, was Peel schützt, etwa eine Mediathek oder eine Wallet. Falls Peel noch keinen Festplattenvollzugriff hat, kann Peel möglicherweise hineinsehen, wenn du ihn in den Systemeinstellungen erteilst."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se toca: macOS no ha dejado que Peel mire dentro para asegurarse de que no hay nada que Peel proteja, como una biblioteca o un monedero digital. Si Peel aún no tiene acceso total al disco, dárselo en Ajustes del Sistema puede permitirle verlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Laissé en place : macOS n’a pas laissé Peel regarder à l’intérieur pour s’assurer qu’aucun élément que Peel protège, comme une bibliothèque ou un portefeuille, ne s’y trouve. Si Peel n’a pas encore l’accès complet au disque, le lui accorder dans Réglages Système peut lui permettre de le voir."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Resta dov’è: macOS non ha permesso a Peel di esaminarne il contenuto per assicurarsi che non contenga nulla di ciò che Peel protegge, come una libreria o un wallet. Se Peel non ha ancora l’accesso completo al disco, concederlo in Impostazioni di Sistema potrebbe permettergli di vederlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "対象外: macOSがPeelに中を調べることを許可しなかったため、ライブラリやウォレットなど、Peelが保護しているものが中にないことを確認できません。Peelにまだフルディスクアクセスがない場合は、システム設定で許可すると確認できるようになる可能性があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "그대로 둠: macOS가 Peel이 안을 살펴보지 못하게 해서 보관함이나 지갑처럼 Peel이 보호하는 항목이 그곳에 없는지 확인할 수 없습니다. Peel에 아직 전체 디스크 접근 권한이 없다면, 시스템 설정에서 권한을 부여하면 볼 수 있을지도 모릅니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Blijft staan: macOS liet Peel er niet in kijken om na te gaan of er niets in zit wat Peel beschermt, zoals een bibliotheek of een wallet. Als Peel nog geen volledige schijftoegang heeft, kan Peel het misschien zien als je die in Systeeminstellingen geeft."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nietknięte: macOS nie pozwolił aplikacji Peel zajrzeć do środka i upewnić się, że nie ma tam niczego, co Peel chroni, na przykład biblioteki lub portfela. Jeśli Peel nie ma jeszcze pełnego dostępu do dysku, nadanie go w Ustawieniach systemowych może to umożliwić."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Preservado: o macOS não deixou o Peel examinar o conteúdo para ter certeza de que não há ali nada do que o Peel protege, como uma biblioteca ou uma carteira. Se o Peel ainda não tem Acesso Total ao Disco, concedê-lo nos Ajustes do Sistema pode permitir que ele veja."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Lăsat neatins: macOS nu i‑a permis aplicației Peel să caute înăuntru pentru a se asigura că acolo nu se află nimic protejat de Peel, cum ar fi o bibliotecă sau un portofel. Dacă Peel nu are încă Acces complet la disc, acordarea acestuia în Configurări sistem îi poate permite să vadă."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Остается на месте: macOS не позволила Peel заглянуть внутрь, чтобы убедиться, что там нет ничего из того, что защищает Peel, например медиатеки или кошелька. Если у Peel еще нет полного доступа к диску, предоставьте его в Системных настройках: возможно, тогда Peel увидит содержимое."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rörs inte: macOS lät inte Peel titta inuti för att kontrollera att inget som Peel skyddar, till exempel ett bibliotek eller en plånbok, finns där. Om Peel ännu inte har full skivtillgång kan Peel kanske se innehållet när du har gett Peel den åtkomsten i Systeminställningar."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yerinde kalır: macOS, Peel’in içine bakıp Peel’in koruduğu hiçbir şeyin, örneğin bir fotoğraf, müzik ya da video arşivi veya bir cüzdan, orada olmadığından emin olmasına izin vermedi. Peel’in henüz Tam Disk Erişimi yoksa, bu izni Sistem Ayarları’nda vermek görmesini sağlayabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Лишається на місці: macOS не дала Peel зазирнути всередину, щоб переконатися, що там немає нічого, що захищає Peel, як-от медіатеки або гаманця. Якщо Peel ще не має повного доступу до диска, його надання в Системних параметрах може дати їй змогу це побачити."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "留在原处:macOS不允许Peel查看其中的内容,因此无法确认里面没有受Peel保护的项目,例如资料库或钱包。如果Peel还没有完全磁盘访问权限,在“系统设置”中授予后,它或许就能看到。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "原地保留:macOS不讓Peel查看其中的內容,因此無法確定裡面沒有任何受Peel保護的項目,例如資料庫或錢包。如果Peel尚未取得「完全取用磁碟」權限,在「系統設定」中給予此權限後,它或許就能看到。"
+ }
+ }
+ }
+ },
"Left alone: only an administrator can move this, and Peel’s helper isn’t allowed to move it from here." : {
"localizations" : {
"cs" : {
@@ -119005,6 +119111,112 @@
}
}
},
+ "Peel won’t move this: macOS wouldn’t let Peel look inside to make sure nothing Peel protects, such as a library or a wallet, is there." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel tuto položku nepřesune: systém macOS nedovolil Peelu nahlédnout dovnitř a ověřit, že tam není nic, co Peel chrání, například knihovna nebo peněženka."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel verschiebt dies nicht: macOS hat Peel nicht hineinsehen lassen, daher kann Peel nicht sicherstellen, dass darin nichts liegt, was Peel schützt, etwa eine Mediathek oder eine Wallet."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no trasladará esto: macOS no ha dejado que Peel mire dentro para asegurarse de que no hay nada que Peel proteja, como una biblioteca o un monedero digital."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel refuse de déplacer cet élément : macOS n’a pas laissé Peel regarder à l’intérieur pour s’assurer qu’aucun élément que Peel protège, comme une bibliothèque ou un portefeuille, ne s’y trouve."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non lo sposta: macOS non ha permesso a Peel di esaminarne il contenuto per assicurarsi che non contenga nulla di ciò che Peel protegge, come una libreria o un wallet."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelはこれを移動しません。macOSがPeelに中を調べることを許可しなかったため、ライブラリやウォレットなど、Peelが保護しているものが中にないことを確認できません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 이 항목을 이동하지 않습니다. macOS가 Peel이 안을 살펴보지 못하게 해서 보관함이나 지갑처럼 Peel이 보호하는 항목이 그곳에 없는지 확인할 수 없기 때문입니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel verplaatst dit niet: macOS liet Peel er niet in kijken om na te gaan of er niets in zit wat Peel beschermt, zoals een bibliotheek of een wallet."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel tego nie przeniesie: macOS nie pozwolił aplikacji Peel zajrzeć do środka i upewnić się, że nie ma tam niczego, co Peel chroni, na przykład biblioteki lub portfela."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não vai mover isto: o macOS não deixou o Peel examinar o conteúdo para ter certeza de que não há ali nada do que o Peel protege, como uma biblioteca ou uma carteira."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu mută acest articol: macOS nu i‑a permis aplicației Peel să caute înăuntru pentru a se asigura că acolo nu se află nimic protejat de Peel, cum ar fi o bibliotecă sau un portofel."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не будет это перемещать: macOS не позволила Peel заглянуть внутрь, чтобы убедиться, что там нет ничего из того, что защищает Peel, например медиатеки или кошелька."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel flyttar inte det här: macOS lät inte Peel titta inuti för att kontrollera att inget som Peel skyddar, till exempel ett bibliotek eller en plånbok, finns där."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel bunu taşımaz: macOS, Peel’in içine bakıp Peel’in koruduğu hiçbir şeyin, örneğin bir fotoğraf, müzik ya da video arşivi veya bir cüzdan, orada olmadığından emin olmasına izin vermedi."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не перемістить це: macOS не дала Peel зазирнути всередину, щоб переконатися, що там немає нічого, що захищає Peel, як-от медіатеки або гаманця."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel不会移动此项:macOS不允许Peel查看其中的内容,因此无法确认里面没有受Peel保护的项目,例如资料库或钱包。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel不會移動此項目:macOS不讓Peel查看其中的內容,因此無法確定裡面沒有任何受Peel保護的項目,例如資料庫或錢包。"
+ }
+ }
+ }
+ },
"Peel won’t move this: something Peel protects is inside, such as a keychain or a wallet." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index a85d1231..54d9a816 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -314,6 +314,7 @@ extension GuardRefusal {
case .holdsDocuments: "holds an app's documents"
case .holdsALibrary: "holds a photo, music, or video library"
case .holdsWorkKeptInACache: "holds work an app keeps nowhere else, such as an editor's local history"
+ case .couldNotLookInside: "macOS wouldn't let Peel look inside to make sure nothing Peel protects is there"
}
}
}
@@ -332,6 +333,7 @@ extension HoldBack {
case .holdsAnExclusion: "holds something you excluded"
case .notMeasured: "not measured in time"
case .couldNotBeRead: "macOS wouldn't let Peel read inside"
+ case .couldNotLookInside: "macOS wouldn't let Peel look inside to make sure nothing Peel protects is there"
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"
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 6bb2c1b8..c4b3ac91 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -1570,7 +1570,7 @@ public enum DeveloperCaches {
guard !folder.rowsAreProjectState || project != nil else { continue }
// Skips a folder that holds work kept nowhere else, such as the state Deno's
// scripts keep in `location_data`. Removing it would lose that work.
- guard !ProtectedData.holdsWorkKeptInACache(url.path(percentEncoded: false)) else { continue }
+ guard ProtectedData.holdsWorkKeptInACache(url.path(percentEncoded: false)) != .found else { continue }
// Skips a symbolic link, which is how people move a big cache to another disk.
// Moving the link frees nothing.
guard (try? url.resourceValues(forKeys: [.isSymbolicLinkKey]).isSymbolicLink) != true else { continue }
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 07e5ecc9..12507d98 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -67,6 +67,9 @@ public enum HoldBack: String, Sendable, Hashable {
/// macOS refused to let Peel read inside, so what the folder holds is not known, and zero would be a wrong
/// size. From macOS 27, another team's container is refused outright rather than prompted for.
case couldNotBeRead
+ /// macOS would not let Peel list a folder inside it, so `RemovalGuard` refuses to move it as the person: what it
+ /// never moves may be in there (`GuardRefusal.couldNotLookInside`).
+ case couldNotLookInside
/// A sandboxed app's container whose `Data/Documents` is not empty or cannot be read. That is where the app
/// keeps what the user made, and `RemovalGuard` refuses to move it.
case holdsDocuments
@@ -145,6 +148,7 @@ public enum HoldBack: String, Sendable, Hashable {
/// would refuse to move it.
public var cannotBeMoved: Bool {
self == .holdsDocuments || self == .holdsALibrary || self == .holdsKeys || self == .holdsWorkKeptInACache
+ || self == .couldNotLookInside
|| self == .beyondTheHelper || self == .leftToItsUninstaller
|| self == .systemExtension || self == .systemExtensionGoingAtRestart || self == .deletableSystemExtension
|| self == .signInPlugIn
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
index e2cdffc9..64bccc20 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
@@ -388,23 +388,27 @@ public struct LeftoverScanner: Sendable {
// A folder that did not answer in time is unknown, not empty: it may hold a repository, and the largest
// folders are the ones that run out of time.
let contents = await measure(url)
+ let path = url.path(percentEncoded: false)
+ let requiresPrivileges = parent.requiresPrivileges(toRemove: url)
+ let wallet = ProtectedData.holdsABrowserWallet(path)
+ let library = ProtectedData.holdsALibrary(path)
+ let work = ProtectedData.holdsWorkKeptInACache(path)
// What the guard will refuse comes first, whatever the walk saw. A folder macOS refuses to open would read
// as empty, and an empty folder of the app's own would be selected. From macOS 27, another team's container
// is refused outright rather than prompted for.
- let heldBack: HoldBack? = if ProtectedData.holds(url.path(percentEncoded: false), home: home)
- || ProtectedData.holdsABrowserWallet(url.path(percentEncoded: false)) {
+ let heldBack: HoldBack? = if ProtectedData.holds(path, home: home) || wallet == .found {
.holdsKeys
- } else if kind == .containers, ProtectedData.holdsAContainersDocuments(url.path(percentEncoded: false)) {
+ } else if kind == .containers, ProtectedData.holdsAContainersDocuments(path) {
.holdsDocuments
- } else if ProtectedData.holdsALibrary(url.path(percentEncoded: false)) {
+ } else if library == .found {
.holdsALibrary
- } else if ProtectedData.holdsWorkKeptInACache(url.path(percentEncoded: false)) {
+ } else if work == .found {
.holdsWorkKeptInACache
+ } else if !requiresPrivileges, [wallet, library, work].contains(.notKnown) {
+ .couldNotLookInside
} else if syncsToOtherDevices(url) {
.inTheCloud
- } else if let keptOnlyHere = KeptOnlyHere.reason(
- for: url.path(percentEncoded: false), home: home, root: root
- ) {
+ } else if let keptOnlyHere = KeptOnlyHere.reason(for: path, home: home, root: root) {
keptOnlyHere
} else if contents?.couldNotBeRead == true {
.couldNotBeRead
@@ -419,7 +423,7 @@ public struct LeftoverScanner: Sendable {
match: heldBack.map(match.forReview) ?? match,
size: contents?.size ?? 0,
isMeasured: contents.map { !$0.couldNotBeRead } ?? false,
- requiresPrivileges: parent.requiresPrivileges(toRemove: url),
+ requiresPrivileges: requiresPrivileges,
holdsDamagedSettings: kind == .preferences && PreferenceFile.isDamaged(url)
)
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
index 02c92131..e4e30403 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
@@ -758,14 +758,20 @@ public struct OrphanScanner: Sendable {
// rewritten in place, so the newest date inside comes from the walk.
let own = try? url.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate
let path = url.path(percentEncoded: false)
+ let requiresPrivileges = parent.requiresPrivileges(toRemove: url)
+ let wallet = ProtectedData.holdsABrowserWallet(path)
+ let library = ProtectedData.holdsALibrary(path)
+ let work = ProtectedData.holdsWorkKeptInACache(path)
let heldBack: HoldBack? = if kind == .containers, ProtectedData.holdsAContainersDocuments(path) {
.holdsDocuments
- } else if ProtectedData.holds(path, home: home) || ProtectedData.holdsABrowserWallet(path) {
+ } else if ProtectedData.holds(path, home: home) || wallet == .found {
.holdsKeys
- } else if ProtectedData.holdsALibrary(path) {
+ } else if library == .found {
.holdsALibrary
- } else if ProtectedData.holdsWorkKeptInACache(path) {
+ } else if work == .found {
.holdsWorkKeptInACache
+ } else if !requiresPrivileges, [wallet, library, work].contains(.notKnown) {
+ .couldNotLookInside
} else if let keptOnlyHere = KeptOnlyHere.reason(for: path, home: home, root: root) {
keptOnlyHere
} else if folder?.holdsWork(at: url) == true {
@@ -782,7 +788,7 @@ public struct OrphanScanner: Sendable {
kind: kind,
size: contents.flatMap { $0.couldNotBeRead ? nil : $0.size },
modificationDate: [own, contents?.newestChange].compactMap(\.self).max(),
- requiresPrivileges: parent.requiresPrivileges(toRemove: url),
+ requiresPrivileges: requiresPrivileges,
heldBack: heldBack,
namedAfter: namedAfter,
holdsDamagedSettings: kind == .preferences && PreferenceFile.isDamaged(url),
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
index 295fee74..034969e4 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
@@ -309,11 +309,11 @@ public struct AppReset: Sendable {
}
/// True for a folder that holds a wallet's or a key's file `ProtectedData` names, or a browser profile with a
- /// wallet in it, which `RemovalGuard` would refuse to move.
+ /// wallet in it, or one Peel can't see all through, which `RemovalGuard` would refuse to move.
private static func holdsKeys(_ url: URL, home: URL) -> Bool {
let path = url.path(percentEncoded: false)
let home = home.path(percentEncoded: false)
return ProtectedData.refuses(path, home: home) || ProtectedData.holds(path, home: home)
- || ProtectedData.holdsABrowserWallet(path)
+ || ProtectedData.holdsABrowserWallet(path) != .nothing
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift
index 6c9dc6f4..d01ff6bf 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift
@@ -23,6 +23,8 @@ public enum GuardRefusal: String, Sendable, Hashable, CaseIterable {
case holdsALibrary
/// Work an app keeps only in a cache folder is inside, such as an editor's local history.
case holdsWorkKeptInACache
+ /// macOS would not let Peel list a folder inside it, so whether something Peel never moves is there is not known.
+ case couldNotLookInside
/// A fixed word for the reason, which the refusal log stores, so a record still reads in a later version.
public var name: String {
@@ -36,6 +38,7 @@ public enum GuardRefusal: String, Sendable, Hashable, CaseIterable {
case .holdsDocuments: "holds-documents"
case .holdsALibrary: "holds-a-library"
case .holdsWorkKeptInACache: "holds-work-kept-in-a-cache"
+ case .couldNotLookInside: "could-not-look-inside"
}
}
@@ -201,6 +204,7 @@ struct RemovalGuard: Sendable {
// Last, since each reads what is a level or two inside the folder, and a name refused above needs none of it.
guard !exclusions.isAnExcludedApp(item ?? URL(filePath: path)) else { return .excluded }
+ var couldNotLookInside = false
for name in names {
guard exclusions.appFolders(inside: URL(filePath: name, directoryHint: .isDirectory)).isEmpty else {
return .excluded
@@ -208,10 +212,16 @@ 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) else { return .holdsDocuments }
- guard !ProtectedData.holdsWorkKeptInACache(name) else { return .holdsWorkKeptInACache }
- guard !ProtectedData.holdsALibrary(name) else { return .holdsALibrary }
- guard !ProtectedData.holdsABrowserWallet(name) else { return .holdsProtectedData }
+ let work = ProtectedData.holdsWorkKeptInACache(name)
+ guard work != .found else { return .holdsWorkKeptInACache }
+ let library = ProtectedData.holdsALibrary(name)
+ guard library != .found else { return .holdsALibrary }
+ let wallet = ProtectedData.holdsABrowserWallet(name)
+ guard wallet != .found else { return .holdsProtectedData }
+ couldNotLookInside = couldNotLookInside || [work, library, wallet].contains(.notKnown)
}
+ // A folder the person can't change moves only through the helper, which looks inside as root first.
+ guard !couldNotLookInside || FileAccess.requiresPrivilegesToRemove(url) else { return .couldNotLookInside }
return nil
}
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift b/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift
index e5d170c8..1705de61 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/BrowserWallets.swift
@@ -251,32 +251,41 @@ extension ProtectedData {
/// 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 {
+ public static func holdsABrowserWallet(_ path: String) -> Finding {
let components = PathComponents.of(path)
- if let profile = profile(sharedBy: components), isAProfileWithAWallet(profile) { return true }
+ if let profile = profile(sharedBy: components), isAProfileWithAWallet(profile) { return .found }
// Only a folder can be a profile or hold one.
var info = stat()
- guard lstat(path, &info) == 0, info.st_mode & S_IFMT == S_IFDIR else { return false }
- if isAProfileWithAWallet(path) { return true }
+ guard lstat(path, &info) == 0, info.st_mode & S_IFMT == S_IFDIR else { return .nothing }
+ if isAProfileWithAWallet(path) { return .found }
let folder = components.last?.lowercased() ?? ""
- return entries(of: path).contains { child in
- if isAWalletsStorage(child.name.lowercased(), in: folder) { return true }
- guard !child.isAFile else { return false }
+ guard let children = entries(of: path) else { return .notKnown }
+ var finding = Finding.nothing
+ for child in children {
+ if isAWalletsStorage(child.name.lowercased(), in: folder) { return .found }
+ guard !child.isAFile else { continue }
let inside = path + "/" + child.name
- return isAProfileWithAWallet(inside)
- || entries(of: inside).contains { !$0.isAFile && isAProfileWithAWallet(inside + "/" + $0.name) }
+ if isAProfileWithAWallet(inside) { return .found }
+ guard let deeper = entries(of: inside) else {
+ finding = .notKnown
+ continue
+ }
+ if deeper.contains(where: { !$0.isAFile && isAProfileWithAWallet(inside + "/" + $0.name) }) { return .found }
}
+ return finding
}
- /// The names in `folder`, each with whether it is a regular file, which is no profile and holds none. The kind
- /// comes with the listing, so a folder of many files costs no call for each file.
- private static func entries(of folder: String) -> [(name: String, isAFile: Bool)] {
- let url = URL(filePath: folder, directoryHint: .isDirectory)
- let found =
- (try? FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: [.isRegularFileKey]))
- ?? []
- return found.map {
+ /// The names in `folder`, each with whether it is a regular file, which is no profile and holds none, or nil for
+ /// a folder macOS would not let this process list. The kind comes with the listing, so a folder of many files
+ /// costs no call for each file.
+ private static func entries(of folder: String) -> [(name: String, isAFile: Bool)]? {
+ let found = listing(folder, followingLinks: false) {
+ try FileManager.default.contentsOfDirectory(
+ at: URL(filePath: $0, directoryHint: .isDirectory), includingPropertiesForKeys: [.isRegularFileKey]
+ )
+ }
+ return found?.map {
($0.lastPathComponent, (try? $0.resourceValues(forKeys: [.isRegularFileKey]))?.isRegularFile == true)
}
}
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift b/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift
index 5d758ffa..7d01c207 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/PrivilegedPathPolicy.swift
@@ -184,9 +184,9 @@ public struct PrivilegedPathPolicy: Sendable {
guard
!ProtectedData.holds(resolved, home: homeDirectory),
!ProtectedData.holdsAContainersDocuments(resolved),
- !ProtectedData.holdsWorkKeptInACache(resolved),
- !ProtectedData.holdsALibrary(resolved),
- !ProtectedData.holdsABrowserWallet(resolved)
+ ProtectedData.holdsWorkKeptInACache(resolved) == .nothing,
+ ProtectedData.holdsALibrary(resolved) == .nothing,
+ ProtectedData.holdsABrowserWallet(resolved) == .nothing
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 d26b2271..2fff9470 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
@@ -295,25 +295,60 @@ public enum ProtectedData: Sendable {
/// the images of its clipboard history, which it keeps on the Mac alone, in `Clipboard` inside its cache folder.
static let workKeptInCaches: Set<String> = ["localhistory", "location_data", "clipboard"]
- /// True for a path under a `Caches` folder that is at or inside one of those folders, or holds one a level
- /// or two down, and for a Library's `Caches` folder holding one three levels down, which is how deep they sit
+ /// Whether a path under a `Caches` folder is at or inside one of those folders, or holds one a level or two
+ /// down, and whether a Library's `Caches` folder holds one three levels down, which is how deep they sit
/// (`Caches/JetBrains/<product>/LocalHistory`). It reads the disk, so it needs the path as spelled on disk.
- public static func holdsWorkKeptInACache(_ path: String) -> Bool {
+ public static func holdsWorkKeptInACache(_ path: String) -> Finding {
let components = PathComponents.of(path).map { $0.lowercased() }
- guard let caches = components.lastIndex(of: "caches") else { return false }
+ guard let caches = components.lastIndex(of: "caches") else { return .nothing }
if caches + 1 == components.count {
- return caches > 0 && components[caches - 1] == "library" && holdsWorkKeptInACache(path, levels: 3)
+ guard caches > 0, components[caches - 1] == "library" else { return .nothing }
+ return holdsWorkKeptInACache(path, levels: 3)
}
- if components[(caches + 1)...].contains(where: workKeptInCaches.contains) { return true }
+ if components[(caches + 1)...].contains(where: workKeptInCaches.contains) { return .found }
return holdsWorkKeptInACache(path, levels: 2)
}
- private static func holdsWorkKeptInACache(_ folder: String, levels: Int) -> Bool {
- guard levels > 0 else { return false }
- let names = (try? FileManager.default.contentsOfDirectory(atPath: folder)) ?? []
- return names.contains { name in
- workKeptInCaches.contains(name.lowercased()) || holdsWorkKeptInACache(folder + "/" + name, levels: levels - 1)
+ private static func holdsWorkKeptInACache(_ folder: String, levels: Int) -> Finding {
+ guard levels > 0 else { return .nothing }
+ guard let names = names(in: folder, followingLinks: true) else { return .notKnown }
+ var finding = Finding.nothing
+ for name in names {
+ if workKeptInCaches.contains(name.lowercased()) { return .found }
+ switch holdsWorkKeptInACache(folder + "/" + name, levels: levels - 1) {
+ case .found: return .found
+ case .notKnown: finding = .notKnown
+ case .nothing: break
+ }
}
+ return finding
+ }
+
+ /// What a look a level or two inside a folder found: what it looked for, nothing, or nothing known, because a
+ /// folder it had to look into is there and could not be listed.
+ public enum Finding: Sendable {
+ case found
+ case nothing
+ case notKnown
+ }
+
+ /// The names in `folder`, none for a path that is not there or is no folder, and nil for a folder macOS would
+ /// not let this process list.
+ static func names(in folder: String, followingLinks: Bool) -> [String]? {
+ listing(folder, followingLinks: followingLinks) { try FileManager.default.contentsOfDirectory(atPath: $0) }
+ }
+
+ /// What `list` gives for `folder`: none for a path that is not there or is no folder, a link to one included unless
+ /// `followingLinks`, and nil when listing a folder that is there fails.
+ static func listing<Entry>(
+ _ folder: String, followingLinks: Bool, _ list: (String) throws -> [Entry]
+ ) -> [Entry]? {
+ var info = stat()
+ guard (followingLinks ? stat(folder, &info) : lstat(folder, &info)) == 0 else {
+ return [ENOENT, ENOTDIR, ELOOP].contains(errno) ? [] : nil
+ }
+ guard info.st_mode & S_IFMT == S_IFDIR else { return [] }
+ return try? list(folder)
}
/// True for a file of the global preferences domain: `.GlobalPreferences.plist`, its `_m` twin, and the
@@ -446,20 +481,28 @@ public enum ProtectedData: Sendable {
librarySuffixes.contains { name.hasSuffix($0) }
}
- /// True for a folder that holds one of those libraries a level or two down, as in
- /// `<year>/<name>.photoslibrary`. A library can sit anywhere, so no list of places can protect the folder
- /// around one, and this looks inside the folder instead. It reads the disk.
- public static func holdsALibrary(_ path: String) -> Bool {
- let folder = URL(filePath: path, directoryHint: .isDirectory)
- let children =
- (try? FileManager.default.contentsOfDirectory(at: folder, includingPropertiesForKeys: [.isDirectoryKey]))
- ?? []
- return children.contains { child in
- if isALibrary(child.lastPathComponent.lowercased()) { return true }
- guard (try? child.resourceValues(forKeys: [.isDirectoryKey]).isDirectory) == true else { return false }
- let deeper = (try? FileManager.default.contentsOfDirectory(atPath: child.path(percentEncoded: false))) ?? []
- return deeper.contains { isALibrary($0.lowercased()) }
+ /// Whether a folder holds one of those libraries a level or two down, as in `<year>/<name>.photoslibrary`. A
+ /// library can sit anywhere, so no list of places can protect the folder around one, and this looks inside the
+ /// folder instead. It reads the disk.
+ public static func holdsALibrary(_ path: String) -> Finding {
+ guard let children = names(in: path, followingLinks: false) else { return .notKnown }
+ var finding = Finding.nothing
+ for child in children {
+ if isALibrary(child.lowercased()) { return .found }
+ let inside = path + "/" + child
+ var info = stat()
+ guard lstat(inside, &info) == 0 else {
+ if errno != ENOENT { finding = .notKnown }
+ continue
+ }
+ guard info.st_mode & S_IFMT == S_IFDIR else { continue }
+ guard let deeper = names(in: inside, followingLinks: false) else {
+ finding = .notKnown
+ continue
+ }
+ if deeper.contains(where: { isALibrary($0.lowercased()) }) { return .found }
}
+ return finding
}
/// The lowercase names a check should compare for `path`: as written, with its `.` and `..` read, and with
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
index 62143d04..ec0f474d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
@@ -876,4 +876,61 @@ struct AttackRemovalGuardTests {
#expect(guardian.allowsRemoval(of: home.appending(path: "Library/Preferences/com.example.app.plist")))
#expect(guardian.allowsRemoval(of: home.appending(path: "Documents/.GlobalPreferences.plist")))
}
+
+ /// What the guard looks for a level or two inside a folder can sit in a folder it may not list, so a folder it
+ /// can't see all through stays. One only the helper can move, the helper looks inside as root.
+ @Test(.permissionsHold) func aFolderItCannotSeeAllThroughStays() throws {
+ let directory = try TemporaryDirectory()
+ let guardian = RemovalGuard(environment: SearchEnvironment(
+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),
+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)
+ ))
+ var folders: [String: URL] = [:]
+ for name in ["Partly", "Open", "Closed"] {
+ try directory.file("home/Library/Caches/org.example.\(name)/kept/state.db")
+ folders[name] = directory.url.appending(path: "home/Library/Caches/org.example.\(name)", directoryHint: .isDirectory)
+ }
+ let closed = ["home/Library/Caches/org.example.Partly/kept", "home/Library/Caches/org.example.Closed"]
+ for folder in closed {
+ try directory.setPermissions(0, of: folder)
+ }
+ defer {
+ for folder in closed {
+ try? directory.setPermissions(0o755, of: folder)
+ }
+ }
+
+ #expect(guardian.refusal(of: try #require(folders["Partly"])) == .couldNotLookInside)
+ #expect(guardian.refusal(of: try #require(folders["Open"])) == nil)
+ #expect(guardian.refusal(of: try #require(folders["Closed"])) == nil)
+ }
+
+ @Test(.permissionsHold) func aLookInsideKnowsWhatItCouldNotSee() throws {
+ let directory = try TemporaryDirectory()
+ let path = { (relative: String) in directory.url.appending(path: relative).path(percentEncoded: false) }
+ try directory.file("Shelf/2019/Summer.photoslibrary/database/Photos.sqlite")
+ try directory.file("Shelf/kept/state.db")
+ try directory.file("Box/kept/state.db")
+ try directory.file("Library/Caches/org.example.Viewer/LocalHistory/changes.storageData")
+ try directory.file("Library/Caches/org.example.Editor/kept/state.db")
+ try directory.file("Profiles/kept/state.db")
+ let closed = ["Shelf/kept", "Box/kept", "Library/Caches/org.example.Editor/kept", "Profiles/kept"]
+ for folder in closed {
+ try directory.setPermissions(0, of: folder)
+ }
+ defer {
+ for folder in closed {
+ try? directory.setPermissions(0o755, of: folder)
+ }
+ }
+
+ #expect(ProtectedData.holdsALibrary(path("Shelf")) == .found)
+ #expect(ProtectedData.holdsALibrary(path("Box")) == .notKnown)
+ #expect(ProtectedData.holdsALibrary(path("Missing")) == .nothing)
+ #expect(ProtectedData.holdsALibrary(path("Library/Caches/org.example.Viewer/LocalHistory/changes.storageData")) == .nothing)
+ #expect(ProtectedData.holdsWorkKeptInACache(path("Library/Caches/org.example.Viewer")) == .found)
+ #expect(ProtectedData.holdsWorkKeptInACache(path("Library/Caches/org.example.Editor")) == .notKnown)
+ #expect(ProtectedData.holdsABrowserWallet(path("Profiles")) == .notKnown)
+ #expect(ProtectedData.holdsABrowserWallet(path("Missing")) == .nothing)
+ }
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift
index a69d998d..f55ba393 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BrowserWalletTests.swift
@@ -109,8 +109,8 @@ struct BrowserWalletTests {
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)))
+ #expect(ProtectedData.holdsABrowserWallet(profile.path(percentEncoded: false)) == .found)
+ #expect(ProtectedData.holdsABrowserWallet(plain.path(percentEncoded: false)) == .nothing)
}
@Test func bravesOwnWalletKeepsItsProfile() throws {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index a9140e5d..7ebdbb72 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -1063,7 +1063,7 @@ struct LeftoverScannerTests {
}
/// A folder inside the leftover that macOS will not open may hold what nothing brings back, as a helper's own
- /// `Private` folder with a wallet in it, so the leftover is not read to the end and is never selected.
+ /// `Private` folder with a wallet in it, so the leftover is not read to the end and is left alone.
@Test(.permissionsHold) func aLeftoverNotReadToTheEndIsNeverSelected() async throws {
let directory = try TemporaryDirectory()
try directory.file("home/Library/Application Support/net.example.client/settings.plist", bytes: 4_096)
@@ -1077,7 +1077,7 @@ struct LeftoverScannerTests {
)
let found = try #require(scan.leftovers.first { $0.url.path(percentEncoded: false).hasSuffix("Application Support/net.example.client") })
- #expect(found.match.heldBack == .couldNotBeRead, "a folder read only in part was taken for all it holds")
+ #expect(found.match.heldBack == .couldNotLookInside, "a folder read only in part was taken for all it holds")
#expect(!found.match.isRecommended)
#expect(!found.isMeasured)
}
@@ -2151,4 +2151,23 @@ struct LeftoverScannerTests {
#expect(found["Caches/Knowledge"]?.match.isRecommended == true)
#expect(found["SyncServices/Knowledge"]?.match.heldBack == .insideAnotherAppsFolder)
}
+
+ @Test(.permissionsHold) func holdsBackAFolderItCannotSeeAllThrough() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Application Support/Tide/kept/state.db")
+ try directory.setPermissions(0, of: "home/Library/Application Support/Tide/kept")
+ defer { try? directory.setPermissions(0o755, of: "home/Library/Application Support/Tide/kept") }
+ let environment = SearchEnvironment(
+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),
+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)
+ )
+ let app = InstalledApp(
+ url: try directory.directory("root/Applications/Tide.app"), bundleIdentifier: "org.example.tide", name: "Tide"
+ )
+
+ let plan = await Uninstallation.prepare(app, installedApps: [app], environment: environment)
+
+ let tide = try #require(plan.scan.leftovers.first { $0.url.lastPathComponent == "Tide" })
+ #expect(tide.match.heldBack == .couldNotLookInside)
+ }
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
index e408aa74..5ec9e74a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
@@ -472,6 +472,19 @@ struct PrivilegedPathPolicyTests {
#expect(!explanation.contains(where: { ("\u{2010}"..."\u{2015}").contains($0) || $0 == "-" }))
}
}
+
+ @Test(.permissionsHold) func refusesAFolderItCannotSeeAllThrough() throws {
+ let directory = try TemporaryDirectory()
+ let policy = try policy(in: directory)
+ for name in ["Partly", "Open"] {
+ try directory.file("root/Library/Caches/org.example.\(name)/kept/state.db")
+ }
+ try directory.setPermissions(0, of: "root/Library/Caches/org.example.Partly/kept")
+ defer { try? directory.setPermissions(0o755, of: "root/Library/Caches/org.example.Partly/kept") }
+
+ #expect(policy.refusal(of: path("root/Library/Caches/org.example.Partly", in: directory)) == .irreplaceable)
+ #expect(policy.refusal(of: path("root/Library/Caches/org.example.Open", in: directory)) == nil)
+ }
}
private extension Result where Failure == PrivilegedPathPolicy.Rejection {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
index 31febce6..a3b6c21e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
@@ -1214,7 +1214,7 @@ struct TrashServiceTests {
#expect(!guardian.allowsRemoval(of: keychains))
#expect(folders.map(accessed) == folders.map { _ in longAgo.tv_sec })
- #expect(!ProtectedData.holdsALibrary(keychains.path(percentEncoded: false)))
+ #expect(ProtectedData.holdsALibrary(keychains.path(percentEncoded: false)) == .nothing)
#expect(accessed(keychains) > longAgo.tv_sec, "listing a folder no longer moves its access time")
}
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 3de80def..ee1e5ebf 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -154,6 +154,7 @@ extension GuardRefusal {
case .holdsDocuments: "Peel won’t move this: an app’s documents are inside."
case .holdsALibrary: "Peel won’t move this: a photo, music, or video library is inside."
case .holdsWorkKeptInACache: "Peel won’t move this: an app keeps work inside that exists nowhere else, such as an editor’s local history."
+ case .couldNotLookInside: "Peel won’t move this: macOS wouldn’t let Peel look inside to make sure nothing Peel protects, such as a library or a wallet, is there."
}
}
}
@@ -293,6 +294,8 @@ extension HoldBack {
"Not selected: this folder took too long to measure, so Peel doesn’t know how big it is or what is inside."
case .couldNotBeRead:
"Not selected: macOS wouldn’t let Peel read inside, so what is in there isn’t known. If Peel doesn’t have Full Disk Access yet, giving it in System Settings may let it see."
+ case .couldNotLookInside:
+ "Left alone: macOS wouldn’t let Peel look inside to make sure nothing Peel protects, such as a library or a wallet, is there. If Peel doesn’t have Full Disk Access yet, giving it in System Settings may let it see."
case .holdsDocuments:
"Left alone: the app’s own Documents folder is inside and may hold what you made with it. Peel never removes that."
case .holdsALibrary:
diff --git a/SAFETY.md b/SAFETY.md
index e789f239..98298649 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -91,6 +91,10 @@ and its key-value databases in `location_data`, and Raycast keeps the images of
inside its cache folder. Those folders, and any cache folder that holds one, stay: emptying "App Caches" in Space
leaves them where they are.
+Peel finds a library, a browser profile with a wallet, or such work by looking a level or two inside a folder. So a
+folder with a folder inside that macOS won't let Peel list stays too, since what is in there isn't known, and its row
+says so. A folder only an administrator can move is looked into by Peel's helper instead, as root, before it moves it.
+
Also refused: a sandboxed app's own `Data/Documents`, which is where that app keeps *your* work, not its
settings. The rule holds for the folder around it too: while `Data/Documents` holds anything, or cannot be
read, the app's whole container stays, and Peel shows it with the reason instead of selecting it. The folders