Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Judge a browser's manifest by the program it runs wherever it is found
Țugui Dragoșc1e7924a0eee
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swiftindex bbdafef9..bd35d302 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift@@ -227,7 +227,7 @@ public struct LeftoverScanner: Sendable {let leftovers = await measured(toMeasure, kind: location.kind, home: home, measure: measure)let inside = await nested(- in: nobodysFolders, of: location, matcher: matcher, home: home, exclusions: exclusions,+ in: nobodysFolders, of: location, matcher: matcher, home: home, bundle: bundle, exclusions: exclusions,measure: measure, refuses: refuses, limit: nestedFolderLimit)return .found(@@ -243,6 +243,7 @@ public struct LeftoverScanner: Sendable {of location: SearchLocation,matcher: LeftoverMatcher,home: String,+ bundle: String,exclusions: Exclusions,measure: @escaping Measure,refuses: Refuses,@@ -253,7 +254,10 @@ public struct LeftoverScanner: Sendable {let search: NestedSearch.Findings<Found> = await NestedSearch.walk(inside: folders, limit: limit) {url, name, parent, canLookInside inlet path = url.path(percentEncoded: false)- if let match = Self.match(name, at: url, kind: kind, matcher: matcher), match.confidence >= .likely,+ // A browser's manifest is whoever's program it runs, whatever it is called.+ let match = url.deletingLastPathComponent().lastPathComponent.lowercased() == "nativemessaginghosts"+ ? runsSomethingInside(bundle, manifest: url) : Self.match(name, at: url, kind: kind, matcher: matcher)+ if let match, match.confidence >= .likely,!isSharedWithTheWholeMac(url, home: home) {guard !refuses(path, home), !exclusions.excludes(url) else { return .pass }// Whose the folders on the way are decides what its name is worth.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex a9d86d04..22fa1a67 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -1607,6 +1607,31 @@ struct LeftoverScannerTests {#expect(manifests.first?.match.isRecommended == true)}+ /// Only the program a manifest runs says whose it is, wherever its NativeMessagingHosts folder sits: one named+ /// after this app's identifier but running another program is not this app's, and one in a browser's folder that+ /// is not listed is found by its program all the same.+ @Test func judgesEveryManifestByTheProgramItRuns() async throws {+ let directory = try TemporaryDirectory()+ let firefox = "home/Library/Application Support/Mozilla/NativeMessagingHosts"+ try directory.file("\(firefox)/net.example.client.remote.json", contents: Data("""+ {"name": "net.example.client.remote", "path": "/Library/PrivilegedHelperTools/Remote.app/host", "type": "stdio"}+ """.utf8))+ let unlisted = "home/Library/Application Support/Seabird/NativeMessagingHosts"+ try directory.file("\(unlisted)/com.example.bridge.json", contents: Data("""+ {"name": "com.example.bridge", "path": "/Applications/Tunewell.app/Contents/MacOS/bridge", "type": "stdio"}+ """.utf8))+ let scanner = LeftoverScanner(environment: environment(in: directory))++ let scan = await scanner.scan(tunewell, installedApps: [tunewell])++ let manifests = Dictionary(uniqueKeysWithValues: scan.leftovers.filter { $0.url.pathExtension == "json" }.map {+ ($0.url.lastPathComponent, $0)+ })+ #expect(manifests["net.example.client.remote.json"] == nil, "another program's manifest was taken on its name")+ #expect(manifests["com.example.bridge.json"]?.match.reason == .nativeMessagingHost)+ #expect(manifests["com.example.bridge.json"]?.match.isRecommended == true)+ }+@Test func aFolderWithAPasswordDatabaseOrItsKeyFileIsNeverSelected() async throws {let directory = try TemporaryDirectory()try directory.file("home/Library/Application Support/Tunewell/Backups/Passwords.kdbx")