1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 11:31:46 +00:00
Commit Graph

75 Commits

Author SHA1 Message Date
tw93
579c963940 uninstall: refine protection flow and menu filtering 2026-02-03 17:36:15 +08:00
tw93
a5c7abd227 refactor: optimize raycast cleanup code structure
Improve code readability and maintainability:
- Simplify conditional logic with chained operators
- Add clarifying comments for different cleanup scopes
- Rename variables for better semantic clarity
- Maintain consistent style with other app cleanup patterns
2026-02-03 14:53:10 +08:00
Andrei Murariu
4f3eb0eb62 bug-fix: uninstall raycast leftovers (#404) 2026-02-03 14:47:44 +08:00
tw93
82d46ee286 fix: refine clash pattern matching for data protection and improve spinner handling 2026-02-01 09:28:49 +08:00
tw93
8ac71a3937 fix: add clash patterns to data protection checks 2026-01-31 20:05:38 +08:00
tw93
15bb60c531 perf: fix should_protect_data performance regression with case optimization
Issue #393 reported mo clean hanging on 'Scanning sandboxed apps'
and 'Scanning orphaned app resources'.

Root cause: should_protect_data() was looping through 332 patterns
(28 SYSTEM_CRITICAL_BUNDLES_FAST + 304 DATA_PROTECTED_BUNDLES).
For 662 sandboxed containers, this resulted in 220,000+ pattern matches.

Solution: Replace loops with fast case statement for common prefixes:
- com.apple.* (system apps) - instant return
- com.microsoft.*, com.jetbrains.* (IDEs) - instant return
- Password managers, VPNs, Docker etc. - instant return
- Other apps - instant return (no protection needed)
- Only check detailed list for special wildcards (com.tencent.* etc.)

Performance: Clean command maintains 35s (same as previous optimization)
Functionality: All 9 protection tests pass
2026-01-31 11:54:26 +08:00
tw93
9d2c907c08 perf: optimize app protection with dual-array strategy and lazy loading
- Add SYSTEM_CRITICAL_BUNDLES_FAST (30 items) for clean operations
- Keep SYSTEM_CRITICAL_BUNDLES (60+ items) for uninstall precision
- Implement lazy regex loading - only build when uninstall is triggered
- Use fast wildcard matching for should_protect_data (clean scenario)
- Use detailed regex matching for should_protect_from_uninstall

Performance improvement:
- Clean command: 71s → 35s (51% faster)
- System CPU: 17.3s → 5.9s (66% reduction)
- Now 27% faster than v1.23.2 baseline (48s → 35s)

Fixes performance regression introduced in commit 2865a78 where
SYSTEM_CRITICAL_BUNDLES expanded from 5 wildcards to 60+ explicit entries.
2026-01-31 11:31:51 +08:00
tw93
e81be16031 perf: optimize scanner timer usage and app protection matching
- Replace time.After() with reusable timer to reduce GC pressure
- Use pre-compiled regex for app bundle matching (O(1) vs O(N))
- Fix Bash 3.2 compatibility (remove local -n usage)
2026-01-30 15:37:13 +08:00
tw93
2865a788e8 test: add checks for uninstallable Apple apps in should_protect_from_uninstall function 2026-01-30 13:57:43 +08:00
tw93
6f0255c56e fix(uninstall): enhance app leftover detection with naming variants (#377) 2026-01-28 19:06:52 +08:00
tw93
3919a70300 fix: enhance uninstall security per audit review
- Validate bundle_id format (reverse-DNS) in stop_launch_services() to prevent glob injection attacks
    - Add common word exclusion list for LaunchAgents name search to avoid false positive matches (Music, Notes, Photos, etc.) - Add security comments explaining symlink handling in remove_file_list()
    - Improve brew_uninstall_cask() timeout handling: exit code 124 now returns failure immediately
    - Update SECURITY_AUDIT.md with remediation details
2026-01-26 20:27:46 +08:00
Tw93
d044b2876e Fix unable to uninstall data-protected apps like Clash Party
Previously, apps matching DATA_PROTECTED_BUNDLES patterns (VPNs, dev tools, etc.)
could not be uninstalled because should_protect_path blocked their deletion.
Now use MOLE_UNINSTALL_MODE to distinguish between cleanup and explicit uninstall,
allowing users to remove these apps when they choose to while still protecting
their data during normal cleanup operations.

Also allow deletion of installer receipts in /private/var/db/receipts/.
2026-01-20 11:54:17 +08:00
Tw93
b9072c2389 chore: auto format code 2026-01-17 01:59:47 +00:00
Tw93
234dad5531 Merge branch 'main' of github.com:tw93/Mole 2026-01-17 09:58:13 +08:00
Tw93
bacc782e41 ShellCheck SC2001 Warning 2026-01-17 09:58:08 +08:00
Tw93
fe296de814 chore: auto format code 2026-01-17 01:53:40 +00:00
Tw93
060c48c48d refactor: enhance uninstall safety and fix dock removal
- Add symlink/bundle_id/BOM validation to prevent injection attacks
- Fix Dock removal for /Applications symlink (use pwd not pwd -P)
- Fix brew uninstall test hanging (skip sudo in non-interactive mode)
- Remove unused SENSITIVE_DATA_REGEX
2026-01-17 09:49:42 +08:00
Tw93
7a46aa04db security: harden BOM processing and LaunchAgents detection
- Add path traversal protection in BOM receipt parsing
- Remove invalid ~/Library/LaunchDaemons path references
- Strengthen LaunchAgents matching (min 5 chars, exclude com.apple.*)
- Add 300s timeout to brew cask uninstall to prevent hangs
Addresses security review findings from V1.21.0 audit.
2026-01-17 09:08:41 +08:00
Tw93
06342de24f security: restrict BOM whitelist to prevent shared component deletion
- Removes shared directories (Frameworks, Plugins, etc) from receipt scanning whitelist
- Ensures that uninstalling an app won't accidentally delete shared system libraries
- Updates SECURITY_AUDIT.md to reflect stricter receipt scanning policy
2026-01-16 09:54:36 +08:00
Tw93
2cecb881a9 docs: update SECURITY_AUDIT for receipt processing safety
- Document /private path exceptions for safe cleanup
- Add receipt file filtering details
- Auto-format shell scripts (shellcheck)
2026-01-15 21:02:13 +08:00
Tw93
7dc854cf30 fix(uninstall): enhance receipt file processing safety and prevent system file deletion
CRITICAL SECURITY FIX

Enhanced the receipt file parsing in uninstall operations to prevent
accidental deletion of critical system files while maintaining deep
cleanup capabilities.

Changes:
- Tightened whitelist in find_app_receipt_files() to exclude /Users/*,
  /usr/*, and /opt/* broad patterns
- Added explicit blacklist for /private/* with safe exceptions for
  logs, temp files, and diagnostic data
- Integrated should_protect_path() check for additional protection
- Added file deduplication with sort -u to prevent duplicate deletions
- Removed dry-run feature from batch uninstall (unused entry point)

Path Protection:
 Blocked: /etc/passwd, /var/db/*, /private/etc/*, all system binaries
 Allowed: /Applications/*, specific /Library/* subdirs, safe /private/* paths
 Additional: Keychain files, system preferences via should_protect_path()

This fixes a critical security issue where parsing .bom receipt files
could result in deletion of system files like /etc/passwd and /var/db/*,
leading to system corruption and data loss.

Affects: V1.12.14 and later versions
Testing: Validated against critical system paths, all blocked correctly
2026-01-15 21:01:11 +08:00
Tw93
3b517c7a6b Merge branch 'dev' into fix/harden-brew-uninstall 2026-01-15 14:00:20 +08:00
Tw93
c34d91b36f feat: enhance uninstall with launch items and login items cleanup
- Add automatic cleanup of LaunchAgents/Daemons (Issue #315)
- Support both system and user-level launch paths
- Add Login Items cleanup (fixing broken entries like CodexBar)
- Improve Homebrew uninstall logging visibility
- Update security audit and tests
2026-01-15 11:39:33 +08:00
Jack Phallen
9f441eea86 Fix unrelated test failures
Fixed WHITELIST_PATTERNS unbound variable error in lib/core/app_protection.sh
Updated clean_empty_library_items to match current behavior
2026-01-14 09:29:05 -05:00
Tw93
00a712711e chore: auto format code 2026-01-14 03:59:21 +00:00
Tw93
0a632c0a22 fix: protect Firefox browser data from cleaning
Fixes #307

- Add Firefox to DATA_PROTECTED_BUNDLES to prevent cleaning
- Protects IndexedDB, localStorage, and other complex storage
- Prevents Gmail and other web apps from breaking after clean
2026-01-14 11:26:24 +08:00
Tw93
ce8989d3e9 chore: auto format code 2026-01-09 06:44:51 +00:00
Tw93
e33e428569 fix: add KeePassXC new bundle id to protection list (#285) 2026-01-09 14:43:50 +08:00
Tw93
2fac1e1dea Merge branch 'main' of github.com:tw93/Mole 2026-01-04 23:21:37 +08:00
Tw93
e434a1e837 feat(uninstall): add support for third-party input methods
- Add '/Library/Input Methods' to application scan paths
- Unprotect Sogou, QQ, and Baidu input methods from system critical list
- Enhance file cleanup logic to detect input method plugins and caches
- Allow clean uninstallation and deep cleaning of WeType, Sogou, etc.
2026-01-04 23:19:02 +08:00
Tw93
b044fa3e60 chore: auto format code 2026-01-04 09:52:09 +00:00
Tw93
3906c020fe fix: improve cleanup by exiting alt screen and refine whitelisting for directory paths and R renv cache. 2026-01-04 17:41:14 +08:00
Jack Phallen
70e1544490 fix: Respect whitelisted subdirectories 2026-01-04 00:00:28 -08:00
Tw93
6dfd675417 refactor: standardize epoch time retrieval with get_epoch_seconds and ensure locale-independent string transformations. 2026-01-03 18:07:47 +08:00
Tw93
9aa569cbb6 feat: Enhance clean, optimize, analyze, and status commands, and update security audit documentation. 2025-12-31 16:23:31 +08:00
Tw93
6c1fcd23d7 feat: optimize clean operation performance by pre-expanding whitelist patterns, improving size calculation, and adapting parallel processing based on file types, alongside test suite enhancements. 2025-12-30 17:13:43 +08:00
Tw93
dab8136da5 chore: auto format code 2025-12-30 06:46:48 +00:00
Tw93
91351d9440 docs: clarify comment for 1Password sync helpers 2025-12-30 14:46:02 +08:00
Tw93
8711c5b5fc feat: add cloud storage protection and bump version to 1.16.2
- Protect Dropbox, OneDrive, Google Drive, Backblaze, Box (Issue #204)
- Add homebrew.mxcl.* services protection
- Document mo optimize --dry-run in help and README
- Bump version to 1.16.2
2025-12-30 14:38:22 +08:00
Tw93
b67204f959 feat: remove SQLite vacuum optimization, enhance CJK/emoji width calculation, and improve system cleanup and UI feedback. 2025-12-29 00:29:42 +08:00
Tw93
50e47a3cd9 chore: bump version to 1.15.3 and update the security audit report following core protection and file operation refinements. 2025-12-28 21:30:39 +08:00
Tw93
b044f1ced7 chore: auto format code 2025-12-28 01:40:26 +00:00
Tw93
c8e33931c2 refactor: centralize whitelist path checking with a new is_path_whitelisted helper function 2025-12-28 09:21:04 +08:00
Ruben Nogueira
21bf7392c9 feat: legcord 2025-12-26 11:58:37 +00:00
Tw93
80903729a3 chore: auto format code 2025-12-25 03:50:34 +00:00
Tw93
babab8e1a3 Fix the error judgment problem of uninstalling the silent writing software 2025-12-25 11:45:52 +08:00
Tw93
952b2eea61 fix: Enhance uninstall robustness with base64
compatibility and cleanup improvements

- Fix field count
  mismatch and base64 BSD/GNU compatibility
  - Add sensitive data detection and macOS defaults cleanup
  - Improve error handling and add compatibility tests
2025-12-25 11:24:12 +08:00
Tw93
ae82c83714 chore: auto format code 2025-12-22 03:24:39 +00:00
Tw93
d2dc68da90 feat: Enhance app protection with centralized critical component checks, improve UI string width calculation, refine analysis and cleaning logic, and add new tests. 2025-12-22 11:24:04 +08:00
Tw93
f8765ee3d3 feat: optimize application scanning performance, improve multi-selection robustness 2025-12-22 09:46:10 +08:00