Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.
Swift cache-cleanercleanmymaccleanupdisk-cleanerdisk-spacehomebrewmac-utilitymacosmacos-appmacos-cleanermacosxnativeossosxprivacyswiftswiftuisystem-cleanerxcode-cleaner
Release 2.1.0: security hardening, UI fixes, version sync
moamen8bc7653d865c
diff --git a/PureMac.xcodeproj/project.pbxproj b/PureMac.xcodeproj/project.pbxprojindex f70a98d..da6d40f 100644--- a/PureMac.xcodeproj/project.pbxproj+++ b/PureMac.xcodeproj/project.pbxproj@@ -49,6 +49,7 @@28181F034530331A550C6A3D /* SchedulerService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchedulerService.swift; sourceTree = "<group>"; };2A8DE5D45BA19E2670B57DC5 /* CleaningEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CleaningEngine.swift; sourceTree = "<group>"; };311078221878708524283765 /* PureMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PureMac.app; sourceTree = BUILT_PRODUCTS_DIR; };+ 340D303C60FF878B019056B6 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };3667D46D8E2004EB4D73835A /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };3A8D39C3C250F26302EC45AB /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };3D4FD34378988D430A582ED0 /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = "<group>"; };@@ -57,6 +58,7 @@4AE790496C936424EF98320A /* OrphanSafetyPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrphanSafetyPolicy.swift; sourceTree = "<group>"; };5664D2BDAEAA9AE3A53DB364 /* PureMac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PureMac.entitlements; sourceTree = "<group>"; };5785762276FB5E3209C6DE4D /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };+ 5A5C80929EE4A430272674BC /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };60E6BC61614B27C065BB18C9 /* AppListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppListView.swift; sourceTree = "<group>"; };63581B70F9B10231964E3602 /* PureMacApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PureMacApp.swift; sourceTree = "<group>"; };77D3D9A9BC52839E6D0A22BC /* Locations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Locations.swift; sourceTree = "<group>"; };@@ -276,6 +278,8 @@knownRegions = (Base,en,+ es,+ ja,"zh-Hans","zh-Hant",);@@ -345,6 +349,8 @@isa = PBXVariantGroup;children = (9F04B811BB0012F6D2F07F91 /* en */,+ 340D303C60FF878B019056B6 /* es */,+ 5A5C80929EE4A430272674BC /* ja */,2641C6376DD6F5889F35510E /* zh-Hans */,02E502E2B5C6AECC76E5CFEF /* zh-Hant */,);@@ -394,7 +400,7 @@CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;COPY_PHASE_STRIP = NO;- CURRENT_PROJECT_VERSION = 4;+ CURRENT_PROJECT_VERSION = 5;DEBUG_INFORMATION_FORMAT = dwarf;DEVELOPMENT_TEAM = H3WXHVTP97;ENABLE_STRICT_OBJC_MSGSEND = YES;@@ -416,7 +422,7 @@GENERATE_INFOPLIST_FILE = NO;INFOPLIST_FILE = PureMac/Info.plist;MACOSX_DEPLOYMENT_TARGET = 13.0;- MARKETING_VERSION = 2.0.0;+ MARKETING_VERSION = 2.1.0;MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;MTL_FAST_MATH = YES;ONLY_ACTIVE_ARCH = NO;@@ -484,7 +490,7 @@CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;COPY_PHASE_STRIP = NO;- CURRENT_PROJECT_VERSION = 4;+ CURRENT_PROJECT_VERSION = 5;DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";DEVELOPMENT_TEAM = H3WXHVTP97;ENABLE_NS_ASSERTIONS = NO;@@ -500,7 +506,7 @@GENERATE_INFOPLIST_FILE = NO;INFOPLIST_FILE = PureMac/Info.plist;MACOSX_DEPLOYMENT_TARGET = 13.0;- MARKETING_VERSION = 2.0.0;+ MARKETING_VERSION = 2.1.0;MTL_ENABLE_DEBUG_INFO = NO;MTL_FAST_MATH = YES;ONLY_ACTIVE_ARCH = NO;diff --git a/PureMac/Info.plist b/PureMac/Info.plistindex 2007cd2..37c8bfe 100644--- a/PureMac/Info.plist+++ b/PureMac/Info.plist@@ -15,9 +15,9 @@<key>CFBundlePackageType</key><string>APPL</string><key>CFBundleShortVersionString</key>- <string>1.0.1</string>+ <string>$(MARKETING_VERSION)</string><key>CFBundleVersion</key>- <string>3</string>+ <string>$(CURRENT_PROJECT_VERSION)</string><key>LSMinimumSystemVersion</key><string>$(MACOSX_DEPLOYMENT_TARGET)</string><key>LSApplicationCategoryType</key>diff --git a/PureMac/Logic/Scanning/AppPathFinder.swift b/PureMac/Logic/Scanning/AppPathFinder.swiftindex e79535b..b058074 100644--- a/PureMac/Logic/Scanning/AppPathFinder.swift+++ b/PureMac/Logic/Scanning/AppPathFinder.swift@@ -193,18 +193,36 @@ class AppPathFinder {// MARK: - Matching Engine+ // Minimum token length required for a name-based match to pass. Prevents+ // a malicious app named "s-s-h" (normalized "ssh", 3 chars) from+ // short-name-bombing home dotfiles like ~/.ssh into the uninstall list.+ private static let minMatchTokenLength = 5++ /// Anchored check for whether `self.normalizedBundleID` belongs to the+ /// family identified by `conditionBundleID`. Accepts exact equality,+ /// ".child" extension, or "parent." suffix - rejects a bundle ID that+ /// merely contains the condition string as a substring. This prevents+ /// `com.evil.jetbrainsapp` from hijacking the `jetbrains` rule.+ private func bundleIDMatchesCondition(_ conditionBundleID: String) -> Bool {+ guard !conditionBundleID.isEmpty else { return false }+ if normalizedBundleID == conditionBundleID { return true }+ if normalizedBundleID.hasPrefix(conditionBundleID + ".") { return true }+ if normalizedBundleID.hasSuffix("." + conditionBundleID) { return true }+ return false+ }+/// Multi-level heuristic matcher. Returns true if the normalized filename/// belongs to the target app at the current sensitivity level.private func matchesApp(normalizedName: String, itemURL: URL) -> Bool {- // Per-app condition overrides take priority+ // Per-app condition overrides take priority. Anchor the bundle ID+ // check (see bundleIDMatchesCondition above).for condition in appConditions {- if normalizedBundleID.contains(condition.bundleID) {- if condition.excludeTerms.contains(where: { normalizedName.contains($0) }) {- return false- }- if condition.includeTerms.contains(where: { normalizedName.contains($0) }) {- return true- }+ guard bundleIDMatchesCondition(condition.bundleID) else { continue }+ if condition.excludeTerms.contains(where: { normalizedName.contains($0) }) {+ return false+ }+ if condition.includeTerms.contains(where: { normalizedName.contains($0) }) {+ return true}}@@ -221,17 +239,18 @@ class AppPathFinder {// Level 2: App namelet isStrict = sensitivity == .strict- let appNameMatch = !normalizedAppName.isEmpty && (isStrict+ let minLen = AppPathFinder.minMatchTokenLength+ let appNameMatch = normalizedAppName.count >= minLen && (isStrict? normalizedName == normalizedAppName: normalizedName.contains(normalizedAppName))// Level 3: Path component name (the .app directory name without extension)- let pathMatch = !pathComponentName.isEmpty && (isStrict+ let pathMatch = pathComponentName.count >= minLen && (isStrict? normalizedName == pathComponentName: normalizedName.contains(pathComponentName))// Level 4: Letters-only app name- let lettersMatch = !appNameLettersOnly.isEmpty && (isStrict+ let lettersMatch = appNameLettersOnly.count >= minLen && (isStrict? normalizedName == appNameLettersOnly: normalizedName.contains(appNameLettersOnly))@@ -242,22 +261,22 @@ class AppPathFinder {// Enhanced mode: additional partial matching strategiesif sensitivity != .strict {// Level 5: Last two bundle ID components- if normalizedName.contains(bundleLastTwo) { return true }+ if bundleLastTwo.count >= minLen, normalizedName.contains(bundleLastTwo) { return true }// Level 6: Base bundle ID (strips .helper/.agent/.daemon suffixes)- if let base = baseBundleID, !base.isEmpty, normalizedName.contains(base) { return true }+ if let base = baseBundleID, base.count >= minLen, normalizedName.contains(base) { return true }// Level 7: Version-stripped app name- if let stripped = strippedAppName, normalizedName.contains(stripped) { return true }+ if let stripped = strippedAppName, stripped.count >= minLen, normalizedName.contains(stripped) { return true }}// Deep mode: broadest matching heuristicsif sensitivity == .deep {// Level 8: Company name extracted from bundle ID- if let company = companyName, !company.isEmpty, normalizedName.contains(company) { return true }+ if let company = companyName, company.count >= minLen, normalizedName.contains(company) { return true }// Level 9: Team identifier from code signature- if let teamID = normalizedTeamID, !teamID.isEmpty, normalizedName.contains(teamID) { return true }+ if let teamID = normalizedTeamID, teamID.count >= minLen, normalizedName.contains(teamID) { return true }}return false@@ -308,8 +327,11 @@ class AppPathFinder {}}- // Named containers matching the bundle ID directly- if dirName.normalizedForMatching() == normalizedBundleID {+ // Named containers matching the bundle ID directly. Require the+ // bundle ID itself to be at least 5 chars to avoid picking up a+ // container owned by an app with a degenerate bundle identifier.+ if normalizedBundleID.count >= 5,+ dirName.normalizedForMatching() == normalizedBundleID {containers.append(dir)}}@@ -323,18 +345,17 @@ class AppPathFinder {/// the main scan has completed.private func applyConditions() {for condition in appConditions {- if normalizedBundleID.contains(condition.bundleID) {- if let paths = condition.forceIncludePaths {- for path in paths {- if FileManager.default.fileExists(atPath: path.path) {- collectionSet.insert(path)- }+ guard bundleIDMatchesCondition(condition.bundleID) else { continue }+ if let paths = condition.forceIncludePaths {+ for path in paths {+ if FileManager.default.fileExists(atPath: path.path) {+ collectionSet.insert(path)}}- if let paths = condition.forceExcludePaths {- for path in paths {- collectionSet.remove(path)- }+ }+ if let paths = condition.forceExcludePaths {+ for path in paths {+ collectionSet.remove(path)}}}diff --git a/PureMac/Logic/Scanning/Conditions.swift b/PureMac/Logic/Scanning/Conditions.swiftindex 0ed4451..d952bed 100644--- a/PureMac/Logic/Scanning/Conditions.swift+++ b/PureMac/Logic/Scanning/Conditions.swift@@ -343,10 +343,53 @@ let skipConditions: [SkipCondition] = ["/System/Volumes/Preboot/Cryptexes/App/System/Library/CoreServices/PasswordManagerBrowserExtensionHelper.app/Contents/MacOS/PasswordManagerBrowserExtensionHelper","\(home)/Library/Application Support/Chromium/NativeMessagingHosts/com.apple.passwordmanager.json","\(home)/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.apple.passwordmanager.json"- ]+ ] + highRiskHomeDotPaths)]+/// Home-directory dotdirs that must never be matched as app artifacts no+/// matter how short or coincidental the app name is. Adding an entry here is+/// the correct fix for "removing webapp X also deleted my CLI tool X config"+/// (see issues #50 / #51).+let highRiskHomeDotPaths: [String] = [+ "\(home)/.claude",+ "\(home)/.ssh",+ "\(home)/.aws",+ "\(home)/.gnupg",+ "\(home)/.gpg",+ "\(home)/.kube",+ "\(home)/.docker",+ "\(home)/.config",+ "\(home)/.git",+ "\(home)/.gitconfig",+ "\(home)/.git-credentials",+ "\(home)/.netrc",+ "\(home)/.npmrc",+ "\(home)/.yarnrc",+ "\(home)/.pnpmrc",+ "\(home)/.pip",+ "\(home)/.pypirc",+ "\(home)/.rbenv",+ "\(home)/.pyenv",+ "\(home)/.nvm",+ "\(home)/.cargo",+ "\(home)/.rustup",+ "\(home)/.gem",+ "\(home)/.local",+ "\(home)/.password-store",+ "\(home)/.mozilla",+ "\(home)/.wine",+ "\(home)/.vscode",+ "\(home)/.vim",+ "\(home)/.viminfo",+ "\(home)/.zshrc",+ "\(home)/.zsh_history",+ "\(home)/.bash_history",+ "\(home)/.bashrc",+ "\(home)/.bash_profile",+ "\(home)/.profile",+]+// MARK: - Deep Search Exclusions/// Library subdirectories excluded from depth=2 (deep) search.diff --git a/PureMac/Logic/Scanning/Locations.swift b/PureMac/Logic/Scanning/Locations.swiftindex 9bb9067..ea7c44b 100644--- a/PureMac/Logic/Scanning/Locations.swift+++ b/PureMac/Logic/Scanning/Locations.swift@@ -40,8 +40,11 @@ class Locations: ObservableObject {self.tempDir = tempDirself.appSearch = SearchCategory(name: "Apps", paths: [- // User home- "\(home)",+ // User home - bare "\(home)" is intentionally NOT scanned.+ // Scanning bare $HOME matches top-level dotfiles like .claude,+ // .ssh, .aws, .kube by normalized app-name ("claude" matching+ // ".claude") and invites data loss when uninstalling unrelated+ // webapps. Scoped subdirs below are still scanned."\(home)/.config","\(home)/Documents","\(home)/Desktop",diff --git a/PureMac/Logic/Utilities/OrphanSafetyPolicy.swift b/PureMac/Logic/Utilities/OrphanSafetyPolicy.swiftindex 34b5159..2b79f49 100644--- a/PureMac/Logic/Utilities/OrphanSafetyPolicy.swift+++ b/PureMac/Logic/Utilities/OrphanSafetyPolicy.swift@@ -38,7 +38,22 @@ enum OrphanSafetyPolicy {let path = normalizedPath(url)let lowerPath = path.lowercased()- guard allowedRoots.contains(where: { lowerPath.hasPrefix($0.lowercased()) }) else {+ // Belt-and-suspenders: reject any high-risk home dotpath (defined in+ // Conditions.swift). The allowedRoots filter below would catch most+ // of these, but this early block keeps the rule obvious.+ for root in highRiskHomeDotPaths {+ if path == root || path.hasPrefix(root + "/") {+ return false+ }+ }++ // Require the match to land STRICTLY inside the allowed root, not at a+ // sibling like /tmpfoo. Trailing "/" prevents hasPrefix from matching+ // sibling directories whose names merely start with the root name.+ guard allowedRoots.contains(where: { root in+ let rootWithSlash = root.lowercased() + "/"+ return lowerPath.hasPrefix(rootWithSlash)+ }) else {return false}diff --git a/PureMac/Services/CleaningEngine.swift b/PureMac/Services/CleaningEngine.swiftindex 9dc90fd..c50a450 100644--- a/PureMac/Services/CleaningEngine.swift+++ b/PureMac/Services/CleaningEngine.swift@@ -30,16 +30,41 @@ actor CleaningEngine {let itemURL = URL(fileURLWithPath: item.path)guard fileManager.fileExists(atPath: item.path) else { continue }- // Security: resolve symlinks and validate the real path- let resolved = itemURL.resolvingSymlinksInPath().path- guard isSafeToDelete(resolvedPath: resolved) else {+ // Security: resolve symlinks, validate the real path, delete+ // through the resolved URL. Deleting through the unresolved+ // path lets an attacker-at-same-UID swap a component to a+ // symlink after the check and have us follow it.+ let resolvedURL = itemURL.resolvingSymlinksInPath()+ let resolved = resolvedURL.path++ // Large files surfaced by scanLargeFiles are per-file items+ // under Downloads/Documents/Desktop; those get a narrower check+ // instead of the whole-subtree allow-list.+ let pathAccepted: Bool = {+ if item.category == .largeFiles {+ return isExplicitSingleFileDeletable(resolvedPath: resolved)+ }+ return isSafeToDelete(resolvedPath: resolved)+ }()+ guard pathAccepted else {let msg = "Skipped symlink or unsafe path: \(item.path) -> \(resolved)"Logger.shared.log(msg, level: .warning)result.errors.append(msg)continue}- try fileManager.removeItem(atPath: item.path)+ // Narrow the TOCTOU window: re-resolve right before the delete+ // and require the resolved path to still match. Any concurrent+ // swap between check and delete aborts the operation.+ let reResolved = URL(fileURLWithPath: item.path).resolvingSymlinksInPath().path+ guard reResolved == resolved else {+ let msg = "Aborting delete: path resolution changed between check and unlink for \(item.path)"+ Logger.shared.log(msg, level: .warning)+ result.errors.append(msg)+ continue+ }++ try fileManager.removeItem(at: resolvedURL)result.freedSpace += item.sizeresult.itemsCleaned += 1} catch {@@ -107,7 +132,10 @@ actor CleaningEngine {// MARK: - Helpers/// Validates that a resolved path is safe to delete.- /// Prevents symlink attacks where a link in ~/Library/Caches points to ~/.ssh or ~/Documents.+ /// Prevents symlink attacks where a link in ~/Library/Caches points to ~/.ssh.+ /// Downloads, Documents, and Desktop are intentionally NOT whole-subtree+ /// allow-listed - scanLargeFiles emits per-file items instead, so those+ /// deletions can still happen through the explicit per-item flow.private func isSafeToDelete(resolvedPath: String) -> Bool {let home = fileManager.homeDirectoryForCurrentUser.pathlet allowedRoots = [@@ -123,21 +151,35 @@ actor CleaningEngine {"\(home)/Library/LaunchAgents","\(home)/Library/Mail Downloads","\(home)/.Trash",- "\(home)/Downloads",- "\(home)/Documents",- "\(home)/Desktop","/Library/Caches","/Library/Logs","/private/var/log","/private/var/tmp","/tmp",]- // Reject if resolved path is not inside any allowed root+ // Allow whole-subtree deletion only; require a trailing "/" on the+ // root match so siblings like "/tmpfoo" cannot pass the prefix check.+ let normalized = (resolvedPath as NSString).standardizingPathreturn allowedRoots.contains { root in- resolvedPath.hasPrefix(root)+ let rootWithSeparator = root.hasSuffix("/") ? root : root + "/"+ return normalized.hasPrefix(rootWithSeparator)}}+ /// Allow a single-file delete under Downloads/Documents/Desktop when it+ /// was explicitly surfaced by a scanner (e.g. scanLargeFiles). Whole-subtree+ /// deletion of those roots remains blocked.+ func isExplicitSingleFileDeletable(resolvedPath: String) -> Bool {+ let home = fileManager.homeDirectoryForCurrentUser.path+ let perFileRoots = [+ "\(home)/Downloads/",+ "\(home)/Documents/",+ "\(home)/Desktop/",+ ]+ let normalized = (resolvedPath as NSString).standardizingPath+ return perFileRoots.contains { normalized.hasPrefix($0) }+ }+private func getCurrentFreeSpace() -> Int64 {do {let attrs = try fileManager.attributesOfFileSystem(forPath: "/")diff --git a/PureMac/Services/ScanEngine.swift b/PureMac/Services/ScanEngine.swiftindex 903551b..00bcb8e 100644--- a/PureMac/Services/ScanEngine.swift+++ b/PureMac/Services/ScanEngine.swift@@ -288,7 +288,19 @@ actor ScanEngine {"\(home)/Library/Caches/Homebrew",]- // Detect custom HOMEBREW_CACHE via `brew --cache`+ // Known-good Homebrew cache roots. Any path returned by `brew --cache`+ // that is NOT inside one of these is refused - prevents an attacker+ // setting HOMEBREW_CACHE=$HOME/Documents from steering our cleanup.+ let knownBrewRoots = [+ "\(home)/Library/Caches/Homebrew",+ "/opt/homebrew/Library/Caches",+ "/usr/local/Homebrew/Library/Caches",+ "/Library/Caches/Homebrew",+ ]++ // Detect custom HOMEBREW_CACHE via `brew --cache`. Strip HOMEBREW_*+ // from the child env so an attacker can't steer the output via+ // launchctl setenv, then validate the output against knownBrewRoots.let brewBinPaths = ["/opt/homebrew/bin/brew", "/usr/local/bin/brew"]var detectedCustomCache = falsefor brewBin in brewBinPaths {@@ -296,6 +308,11 @@ actor ScanEngine {let task = Process()task.executableURL = URL(fileURLWithPath: brewBin)task.arguments = ["--cache"]+ var sanitizedEnv = ProcessInfo.processInfo.environment+ for key in Array(sanitizedEnv.keys) where key.hasPrefix("HOMEBREW_") {+ sanitizedEnv.removeValue(forKey: key)+ }+ task.environment = sanitizedEnvlet pipe = Pipe()task.standardOutput = pipetask.standardError = Pipe()@@ -306,6 +323,13 @@ actor ScanEngine {if let output = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines),!output.isEmpty {let normalized = normalizePath(output)+ let isKnown = knownBrewRoots.contains { root in+ normalized == root || normalized.hasPrefix(root + "/")+ }+ guard isKnown else {+ Logger.shared.log("Refusing suspicious brew cache path: \(output)", level: .warning)+ break+ }if !brewCachePaths.map(normalizePath).contains(normalized) {brewCachePaths.append(output)}diff --git a/PureMac/Services/SchedulerService.swift b/PureMac/Services/SchedulerService.swiftindex 59ffd61..fbb87aa 100644--- a/PureMac/Services/SchedulerService.swift+++ b/PureMac/Services/SchedulerService.swift@@ -13,7 +13,16 @@ class SchedulerService: ObservableObject {init() {if let data = UserDefaults.standard.data(forKey: configKey),- let saved = try? JSONDecoder().decode(ScheduleConfig.self, from: data) {+ var saved = try? JSONDecoder().decode(ScheduleConfig.self, from: data) {+ // Refuse to honor an already-past nextRunDate loaded from disk -+ // otherwise an attacker who can write our plist (same-UID foothold)+ // sets nextRunDate to a past timestamp and our first tick after+ // launch triggers autoClean. Reset the schedule so the first run+ // is always at least one full interval after launch.+ if let next = saved.nextRunDate, next.timeIntervalSinceNow < 60 {+ saved.nextRunDate = nil+ saved.lastRunDate = nil+ }self.config = saved} else {self.config = ScheduleConfig()diff --git a/PureMac/ViewModels/AppState.swift b/PureMac/ViewModels/AppState.swiftindex 09ff3ed..891817e 100644--- a/PureMac/ViewModels/AppState.swift+++ b/PureMac/ViewModels/AppState.swift@@ -76,7 +76,13 @@ final class AppState: ObservableObject {scheduler.setTrigger { [weak self] inawait self?.runScheduledScan()}- scheduler.start()+ // Only arm the scheduler once onboarding has completed. Before the+ // first launch the defaults plist may have been attacker-planted with+ // autoClean=true - waiting for onboarding ensures a human consents to+ // auto-clean before we start honoring it.+ if UserDefaults.standard.bool(forKey: "PureMac.OnboardingComplete") {+ scheduler.start()+ }}// MARK: - App Loading@@ -115,8 +121,34 @@ final class AppState: ObservableObject {}func removeSelectedFiles() {- let urls = Array(selectedFiles)+ // Safety guard: never allow a high-risk home dotpath (listed in+ // Conditions.swift) to be sent to trashViaFinder no matter how it+ // ended up in the selection. Catches selection-time additions that+ // slipped past the scanner-side filters.+ let allURLs = Array(selectedFiles)+ let (urls, blocked): ([URL], [URL]) = allURLs.reduce(into: ([], [])) { acc, url in+ let resolved = url.resolvingSymlinksInPath().path+ let isBlocked = highRiskHomeDotPaths.contains { root in+ resolved == root || resolved.hasPrefix(root + "/")+ }+ if isBlocked {+ acc.1.append(url)+ } else {+ acc.0.append(url)+ }+ }removalError = nil+ if !blocked.isEmpty {+ let blockedList = blocked.map(\.path).joined(separator: ", ")+ Logger.shared.log("Refused to delete \(blocked.count) high-risk home dotpath(s): \(blockedList)", level: .warning)+ selectedFiles.subtract(blocked)+ }+ guard !urls.isEmpty else {+ if !blocked.isEmpty {+ removalError = "Refused to delete \(blocked.count) protected item(s) (home credential directory or similar)."+ }+ return+ }trashViaFinder(urls: urls) { [weak self] success inDispatchQueue.main.async {guard let self else { return }diff --git a/PureMac/Views/Apps/AppListView.swift b/PureMac/Views/Apps/AppListView.swiftindex 873ff75..057a2b3 100644--- a/PureMac/Views/Apps/AppListView.swift+++ b/PureMac/Views/Apps/AppListView.swift@@ -4,22 +4,30 @@ struct AppListView: View {@EnvironmentObject var appState: AppState@State private var searchText = ""@State private var selection: InstalledApp.ID?+ @State private var sortOrder: [KeyPathComparator<InstalledApp>] = [+ .init(\.appName, order: .forward)+ ]private var filteredApps: [InstalledApp] {+ let base: [InstalledApp]if searchText.isEmpty {- return appState.installedApps- }- let query = searchText.lowercased()- return appState.installedApps.filter {- $0.appName.lowercased().contains(query) ||- $0.bundleIdentifier.lowercased().contains(query)+ base = appState.installedApps+ } else {+ let query = searchText.lowercased()+ base = appState.installedApps.filter {+ $0.appName.lowercased().contains(query) ||+ $0.bundleIdentifier.lowercased().contains(query)+ }}+ return base.sorted(using: sortOrder)}var body: some View {HSplitView {+ // Cap the left pane's maxWidth so dragging the splitter cannot+ // push it past half the window and break the layout (#60).appTable- .frame(minWidth: 300, idealWidth: 380)+ .frame(minWidth: 300, idealWidth: 380, maxWidth: 600)fileDetail.frame(minWidth: 300)@@ -63,8 +71,8 @@ struct AppListView: View {actionLabel: "Retry")} else {- Table(filteredApps, selection: $selection) {- TableColumn("Application") { app in+ Table(filteredApps, selection: $selection, sortOrder: $sortOrder) {+ TableColumn("Application", value: \.appName) { app inHStack(spacing: 8) {Image(nsImage: app.icon).resizable()@@ -74,7 +82,7 @@ struct AppListView: View {}.width(min: 150)- TableColumn("Size") { app in+ TableColumn("Size", value: \.size) { app inText(app.formattedSize).monospacedDigit().foregroundStyle(.secondary)diff --git a/PureMac/Views/MainWindow.swift b/PureMac/Views/MainWindow.swiftindex 5cf21ae..d01b42c 100644--- a/PureMac/Views/MainWindow.swift+++ b/PureMac/Views/MainWindow.swift@@ -18,9 +18,14 @@ struct MainWindow: View {}}- // All sidebar items as a flat array so ForEach gives proper selectability+ // All sidebar items as a flat array so ForEach gives proper selectability.+ // Smart Scan is pinned to the top so users always have a path back to it -+ // otherwise the landing page disappears after selecting another tab (#69).private var allSidebarItems: [SidebarItem] {+ let smartSize = appState.categoryResults[.smartScan]?.totalSize ?? appState.totalJunkSize+ let smartBadge = smartSize > 0 ? ByteCountFormatter.string(fromByteCount: smartSize, countStyle: .file) : nilvar items: [SidebarItem] = [+ SidebarItem(section: .cleaning(.smartScan), label: CleaningCategory.smartScan.rawValue, icon: CleaningCategory.smartScan.icon, badge: smartBadge, group: "Home"),SidebarItem(section: .apps, label: "Installed Apps", icon: "square.grid.2x2", badge: "\(appState.installedApps.count)", group: "Applications"),SidebarItem(section: .orphans, label: "Orphaned Files", icon: "doc.questionmark", badge: appState.orphanedFiles.count > 0 ? "\(appState.orphanedFiles.count)" : nil, group: "Applications"),]@@ -35,7 +40,7 @@ struct MainWindow: View {private var sidebar: some View {List(selection: $selectedSection) {let grouped = Dictionary(grouping: allSidebarItems, by: \.group)- let order = ["Applications", "Cleaning"]+ let order = ["Home", "Applications", "Cleaning"]ForEach(order, id: \.self) { group inSection(group) {ForEach(grouped[group] ?? [], id: \.section) { item indiff --git a/project.yml b/project.ymlindex b614524..0dce9c2 100644--- a/project.yml+++ b/project.yml@@ -19,8 +19,8 @@ settings:CODE_SIGN_ENTITLEMENTS: "PureMac/PureMac.entitlements"INFOPLIST_FILE: "PureMac/Info.plist"PRODUCT_BUNDLE_IDENTIFIER: "com.puremac.app"- MARKETING_VERSION: "2.0.0"- CURRENT_PROJECT_VERSION: "4"+ MARKETING_VERSION: "2.1.0"+ CURRENT_PROJECT_VERSION: "5"GENERATE_INFOPLIST_FILE: "NO"ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon"COMBINE_HIDPI_IMAGES: "YES"