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
Find the browser manifests an app installs to let its extension run it
Țugui Dragoș682a34327a11
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex f78250d5..5b3a1c60 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -18622,6 +18622,112 @@}}},+ "Browser Extension Helper" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Pomocník rozšíření prohlížeče"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Browsererweiterungshilfe"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Auxiliar de extensión de navegador"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Utilitaire d’extension de navigateur"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Assistente per estensioni browser"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "ブラウザ機能拡張ヘルパー"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "브라우저 확장 보조 프로그램"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Browserextensiehulp"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Narzędzie rozszerzenia przeglądarki"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Auxiliar de Extensão do Navegador"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Instrument pentru extensii de browser"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Служебная программа браузера"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Hjälpverktyg för webbläsartillägg"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tarayıcı Genişletme Yardımcısı"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Помічник розширення браузера"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "浏览器扩展帮助程序"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "瀏覽器延伸功能輔助程式"+ }+ }+ }+ },"Build Artifacts" : {"localizations" : {"cs" : {@@ -63882,6 +63988,112 @@}}},+ "Lets a browser extension run a program inside the app" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Umožňuje rozšíření prohlížeče spouštět program uvnitř aplikace"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Erlaubt einer Browsererweiterung, ein Programm in der App auszuführen"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Permite que una extensión del navegador ejecute un programa de dentro de la app"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Permet à une extension de navigateur d’exécuter un programme situé dans l’app"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Consente a un’estensione del browser di eseguire un programma all’interno dell’app"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "ブラウザの機能拡張がアプリ内のプログラムを実行できるようにする"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "브라우저 확장 프로그램이 앱 내부의 프로그램을 실행하도록 허용"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Laat een browserextensie een programma in de app uitvoeren"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Pozwala rozszerzeniu przeglądarki uruchamiać program z wnętrza aplikacji"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Permite que uma extensão do navegador execute um programa dentro do app"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Permite unei extensii de browser să ruleze un program din interiorul aplicației"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Позволяет расширению браузера запускать программу внутри приложения"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Låter ett webbläsartillägg köra ett program inuti appen"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bir tarayıcı genişletmesinin uygulamanın içindeki bir programı çalıştırmasına izin veriyor"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Дозволяє розширенню браузера запускати виконуваний файл усередині програми"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "允许浏览器扩展运行App内的程序"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "讓瀏覽器延伸功能執行App內的程式"+ }+ }+ }+ },"Lets you uninstall apps and clear leftovers, caches, and duplicates from Terminal. Copy the install command and run it in Terminal: it asks for your password." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex f9d0b277..383fe80a 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -268,6 +268,7 @@ extension MatchReason {case .namePrefix: "name prefix"case .launchdJob: "runs the app"case .linksToTheApp: "leads into the app"+ case .nativeMessagingHost: "lets a browser extension run the app"case .installerReceipt: "installer receipt"case .homebrewCask: "Homebrew cask"}diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex d4f379d4..6622808a 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -13,6 +13,8 @@ public enum MatchReason: String, Sendable, Hashable {case launchdJob/// A link in `/usr/local/bin` or `/usr/local/sbin` that leads to a tool inside the app.case linksToTheApp+ /// A browser's native messaging manifest whose program sits inside the app.+ case nativeMessagingHost/// An installer receipt for this app's identifier, which keeps macOS counting the package as installed.case installerReceipt/// The app's Homebrew cask lists this path in its uninstall or zap stanza.diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swiftindex 8ebd3754..b576f1db 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift@@ -193,7 +193,7 @@ extension LeftoverMatcher {rank = Self.tier(of: reason) * 10_000 + specificityfamily = switch reason {case .bundleIdentifier, .embeddedBundleIdentifier, .applicationGroup, .bundleIdentifierPrefix,- .launchdJob, .linksToTheApp, .installerReceipt:+ .launchdJob, .linksToTheApp, .nativeMessagingHost, .installerReceipt:.identifiercase .name, .namePrefix, .homebrewCask: .namecase .teamIdentifier, .vendorPrefix: .maker@@ -212,8 +212,9 @@ extension LeftoverMatcher {private static func tier(of reason: MatchReason) -> Int {switch reason {- // A job's program or a link's target lies inside the app's bundle, which no other app can share.- case .launchdJob, .linksToTheApp: 8+ // A job's or a manifest's program, or a link's target, lies inside the app's bundle, which no other app+ // can share.+ case .launchdJob, .linksToTheApp, .nativeMessagingHost: 8case .bundleIdentifier, .installerReceipt: 7case .embeddedBundleIdentifier, .applicationGroup: 6case .bundleIdentifierPrefix: 5diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swiftindex c98be722..8a04256d 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift@@ -367,6 +367,7 @@ public struct LeftoverScanner: Sendable {bundle: String) -> LeftoverMatch? {guard kind != .commandLineTools else { return leadsInside(bundle, link: url) }+ guard kind != .nativeMessagingHosts else { return runsSomethingInside(bundle, manifest: url) }guard let inside = runsSomethingInside(bundle, job: url, kind: kind) else {return match(name, at: url, kind: kind, matcher: matcher)}@@ -418,6 +419,17 @@ public struct LeftoverScanner: Sendable {return LeftoverMatch(reason: .launchdJob, confidence: .certain, sharedWith: [])}+ /// A browser's native messaging manifest is the app's when the program it names, an absolute path, is inside it.+ private static func runsSomethingInside(_ bundle: String, manifest url: URL) -> LeftoverMatch? {+ guard url.pathExtension == "json", let data = BoundedRead.data(at: url, maximum: 64 * 1_024),+ let manifest = try? JSONSerialization.jsonObject(with: data) as? [String: Any],+ let program = manifest["path"] as? String, program.hasPrefix("/")+ else { return nil }+ let path = PathPattern.comparablePath(of: URL(filePath: program))+ guard PathComponents.isPath(path, atOrInside: bundle) else { return nil }+ return LeftoverMatch(reason: .nativeMessagingHost, confidence: .certain, sharedWith: [])+ }+/// A link that leads inside the app is that app's, whatever the tool is called. A link that leads anywhere/// else is not claimed. The link is read without following it, and a relative one is taken from its folder.private static func leadsInside(_ bundle: String, link url: URL) -> LeftoverMatch? {diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swiftindex 9dea6c39..03b3c74d 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift@@ -41,6 +41,9 @@ public struct SearchLocation: Sendable, Hashable {/// `/usr/local/bin` and `/usr/local/sbin`, where an app links the command line tools it carries. Only a/// link into the app counts as the app's: a tool is named for what it does (`docker`), not for its maker.case commandLineTools+ /// The folders where a browser looks for the manifests of the programs its extensions may run. A manifest+ /// is named for its host, not for the app, so only one whose program is inside the app counts as the app's.+ case nativeMessagingHosts/// Somewhere no scan looks, which only a Homebrew cask can name: `~/Documents/Foo`, `/usr/local/etc/foo`.case elsewhere}@@ -202,6 +205,10 @@ public struct SearchEnvironment: Sendable {locations += ["usr/local/bin", "usr/local/sbin", "opt/homebrew/bin"].map {SearchLocation(kind: .commandLineTools, url: rootDirectory.appending(path: $0, directoryHint: .isDirectory))}+ let hosts = [(userLibrary, Self.nativeMessagingHosts.user), (localLibrary, Self.nativeMessagingHosts.local)]+ locations += hosts.flatMap { library, folders in+ folders.map { library.appending(path: $0, directoryHint: .isDirectory) }+ }.map { SearchLocation(kind: .nativeMessagingHosts, url: $0) }locations.append(SearchLocation(kind: .sharedFolder,url: rootDirectory.appending(path: "Users/Shared", directoryHint: .isDirectory)@@ -215,6 +222,26 @@ public struct SearchEnvironment: Sendable {return locations}+ /// Each browser's own documentation: Chrome's and Chromium's "Native messaging", MDN's "Native manifests" for+ /// Firefox, and Microsoft's "Native messaging" for Edge and its Beta, Dev, and Canary channels.+ static let nativeMessagingHosts = (+ user: [+ "Application Support/Google/Chrome/NativeMessagingHosts",+ "Application Support/Chromium/NativeMessagingHosts",+ "Application Support/Mozilla/NativeMessagingHosts",+ "Application Support/Microsoft Edge/NativeMessagingHosts",+ "Application Support/Microsoft Edge Beta/NativeMessagingHosts",+ "Application Support/Microsoft Edge Dev/NativeMessagingHosts",+ "Application Support/Microsoft Edge Canary/NativeMessagingHosts",+ ],+ local: [+ "Google/Chrome/NativeMessagingHosts",+ "Application Support/Chromium/NativeMessagingHosts",+ "Application Support/Mozilla/NativeMessagingHosts",+ "Microsoft/Edge/NativeMessagingHosts",+ ]+ )+private static func darwinUserDirectory(_ name: Int32) -> URL? {let length = confstr(name, nil, 0)guard length > 0 else { return nil }diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swiftindex 4807e9b0..78818950 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift@@ -82,7 +82,9 @@ public struct OrphanScanner: Sendable {let results = await withTaskGroup(of: LocationResult.self) { group inlet home = environment.homeDirectory.path(percentEncoded: false)- for location in environment.locations {+ // A browser's manifest is an app's only through the program it names, which an uninstall reads. Here one+ // is still found by the identifier it is named for, inside Application Support.+ for location in environment.locations where location.kind != .nativeMessagingHosts {_ = group.addTaskUnlessCancelled { [exclusions, nestedFolderLimit, walk] inawait Self.scan(location, ownership: ownership, jobs: jobs, goneBundles: goneBundles, goneApps: goneApps,diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swiftindex 8c9c05cb..28a11aa3 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift@@ -97,7 +97,7 @@ public struct AppReset: Sendable {// plug-in or a framework is code that macOS loads, not a setting.case .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems, .plugIns, .frameworks, .receipts,.library,- .sharedFolder, .hiddenHomeFiles, .homeFolder, .commandLineTools, .elsewhere:+ .sharedFolder, .hiddenHomeFiles, .homeFolder, .commandLineTools, .nativeMessagingHosts, .elsewhere:nil}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex 99ed9b34..363892ff 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -1449,6 +1449,25 @@ struct LeftoverScannerTests {#expect(scan.leftovers.first?.match.confidence == .certain)}+ @Test func findsABrowsersManifestThatRunsAProgramInsideTheApp() async throws {+ let directory = try TemporaryDirectory()+ let hosts = "home/Library/Application Support/Google/Chrome/NativeMessagingHosts"+ try directory.file("\(hosts)/com.example.bridge.json", contents: Data("""+ {"name": "com.example.bridge", "path": "/Applications/Tunewell.app/Contents/MacOS/bridge", "type": "stdio"}+ """.utf8))+ try directory.file("\(hosts)/org.example.other.json", contents: Data("""+ {"name": "org.example.other", "path": "/Applications/Other.app/Contents/MacOS/bridge", "type": "stdio"}+ """.utf8))+ let scanner = LeftoverScanner(environment: environment(in: directory))++ let scan = await scanner.scan(tunewell, installedApps: [tunewell])++ let manifests = scan.leftovers.filter { $0.url.pathExtension == "json" }+ #expect(manifests.map(\.url.lastPathComponent) == ["com.example.bridge.json"])+ #expect(manifests.first?.match.confidence == .certain)+ #expect(manifests.first?.match.isRecommended == true)+ }+@Test func aFolderWithAPasswordDatabaseOrItsKeyFileIsNeverSelected() async throws {let directory = try TemporaryDirectory()try directory.file("home/Library/Application Support/Tunewell/Backups/Passwords.kdbx")diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 3de1aada..d361d26e 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -14,6 +14,7 @@ extension MatchReason {case .namePrefix: "Starts with the app’s name"case .launchdJob: "Runs a program inside the app"case .linksToTheApp: "Leads to a tool inside the app"+ case .nativeMessagingHost: "Lets a browser extension run a program inside the app"case .installerReceipt: "The app’s installer receipt"case .homebrewCask: "Listed by the Homebrew cask"}@@ -72,6 +73,7 @@ extension SearchLocation.Kind {case .library: "Library Folder"case .temporaryItems: "Temporary Files"case .commandLineTools: "Command-Line Tool"+ case .nativeMessagingHosts: "Browser Extension Helper"case .elsewhere: "Elsewhere"case .sharedFolder: "Shared Folder"case .hiddenHomeFiles: "Hidden Item"@@ -86,6 +88,7 @@ extension SearchLocation.Kind {case .caches: "archivebox"case .temporaryItems: "hourglass"case .commandLineTools: "terminal"+ case .nativeMessagingHosts: "puzzlepiece.extension"case .elsewhere: "mappin.and.ellipse"case .containers, .groupContainers: "shippingbox"case .preferences, .preferencesByHost: "gearshape"