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.

Say nothing of macOS's OSAnalytics folder that a standard account can't read

Țugui Dragoș8f3f7f3470f9
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SystemFolders.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SystemFolders.swift
index 2cf6240f..79b909d6 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SystemFolders.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SystemFolders.swift
@@ -242,6 +242,11 @@ enum SystemFolders {
"Xsan": .file("/System/Library/ConfigurationProfiles/PlugIns/xsanplugin.profileDomainPlugin/Contents/MacOS/xsanplugin", naming: "Library/Preferences/Xsan"),
]
+ /// At the top of a Library, beside the folders Peel searches one by one.
+ static let library: [String: Proof] = [
+ "OSAnalytics": .file("/System/Library/Sandbox/Profiles/com.apple.analyticsd.sb", naming: "/Library/OSAnalytics"),
+ ]
+
static let webKit: [String: Proof] = [
"Databases": .image("/System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy", naming: "~/Library/WebKit/Databases"),
"JavaScriptCoreDebug": .image("/System/Library/PrivateFrameworks/Safari.framework/Versions/A/Safari", naming: "~/Library/WebKit/JavaScriptCoreDebug"),
@@ -263,6 +268,7 @@ enum SystemFolders {
case .preferences: preferencesNames
case .webKit: webKitNames
case .cookies: cookiesNames
+ case .library: libraryNames
default: noNames
}
return names.hold(fileName)
@@ -274,6 +280,7 @@ enum SystemFolders {
private static let preferencesNames = Names(preferences)
private static let webKitNames = Names(webKit)
private static let cookiesNames = Names(cookies)
+ private static let libraryNames = Names(library)
private static let noNames = Names([:])
/// The names of one list, lowercased, those with a `*` read as patterns.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index 09a4f305..c21ed786 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -1400,6 +1400,25 @@ struct OrphanScannerTests {
#expect(scan.unreadableLocations.map(\.url.lastPathComponent) == ["Example Software"])
}
+ @Test(.permissionsHold) func saysNothingOfAFolderOfMacOSsOwnAtTheTopOfALibrary() async throws {
+ let directory = try TemporaryDirectory()
+ let folders = ["OSAnalytics", "Example Software"]
+ try directory.file("root/Library/OSAnalytics/Diagnostics/report.ips")
+ try directory.file("root/Library/Example Software/org.example.mixer/settings.json")
+ for folder in folders {
+ try directory.setPermissions(0, of: "root/Library/\(folder)")
+ }
+ defer {
+ for folder in folders {
+ try? directory.setPermissions(0o755, of: "root/Library/\(folder)")
+ }
+ }
+
+ let scan = await scanner(in: directory).scan(installedApps: installed)
+
+ #expect(scan.unreadableLocations.map(\.url.lastPathComponent) == ["Example Software"])
+ }
+
@Test func saysWhereItStoppedLookingInsideFolders() async throws {
let directory = try TemporaryDirectory()
try directory.file("home/Library/Application Support/Vendor One/notes.txt")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift
index 5f4be3c4..da16756a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift
@@ -6,7 +6,7 @@ struct SystemFoldersTests {
@Test func everyNameIsProvedByTheSealedSystem() {
let lists = [
SystemFolders.applicationSupport, SystemFolders.caches, SystemFolders.logs, SystemFolders.preferences,
- SystemFolders.webKit, SystemFolders.cookies,
+ SystemFolders.webKit, SystemFolders.cookies, SystemFolders.library,
]
for (name, proof) in lists.joined() {
#expect(Self.holds(proof, for: name), "\(name): \(proof)")