1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 17:24:45 +00:00
Commit Graph

449 Commits

Author SHA1 Message Date
Tw93
12cacaa6cc refactor: enhance pattern detection and symlink safety
- Expand sensitive data patterns (credentials, cloud configs, media folders)
- Add symlink target validation in path deletion checks
- Remove shared Gradle cache from Android Studio cleanup
2026-01-17 09:09:11 +08:00
Tw93
51abd890bc fix: improve Dock cleanup path handling
- Add control character validation
- Use canonical paths (pwd -P) for better resolution
- Strengthen fallback logic for deleted applications
- Add empty path guards
2026-01-17 09:09:02 +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
a7ea5d94a0 chore: auto format code 2026-01-16 07:28:58 +00:00
Tw93
ffa46b03ee fix(uninstall): resolve hang during brew uninstall by exposing output and ensuring sudo 2026-01-16 12:54:21 +08:00
Tw93
7294ef65a1 feat(ui): allow arrow keys and space during search filtering
- Modified FORCE_CHAR mode in read_key() to recognize arrow keys and space
- Users can now navigate and select items while typing in search mode
- Improves UX by eliminating need to press Enter before selecting
- ESC key still works to cancel search

This restores V1.19.0 behavior where navigation worked during search
2026-01-16 11:17:26 +08:00
Tw93
ae95512560 fix(ui): restore real-time search filtering in paginated menu
- Previous perf optimization (318c67f) broke real-time search by removing rebuild_view call
- Now calls rebuild_view and triggers full redraw when typing/deleting
- Uses 'continue' to skip drain_pending_input, preserving fast typed characters
- Fixes issue where only first character was effective in search
2026-01-16 10:51:36 +08:00
Tw93
60ee0e1f9c feat(uninstall): add progress spinner for brew autoremove
- Show 'Checking brew dependencies...' spinner while running brew autoremove
- Prevents user confusion when brew cleanup takes time after uninstall
- Improves UX by providing visual feedback during dependency cleanup
2026-01-16 10:26:46 +08:00
Tw93
d29a0f828b fix(uninstall): fix Dock cleanup by using correct PlistBuddy path
- Changed from `command -v PlistBuddy` to `[[ -x /usr/libexec/PlistBuddy ]]`
- PlistBuddy is not in PATH, it's at /usr/libexec/PlistBuddy on macOS
- Previous code would always return early, making Dock cleanup never work
- Also improved fallback logic for already-deleted apps
- Tested and verified Dock icons are now properly removed after uninstall
2026-01-16 10:19:38 +08:00
Tw93
444bc3a70a chore: auto format code 2026-01-16 02:00:46 +00: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
93953abad6 fix: remove insecure empty folder cleanup logic to prevent critical data loss (#320)
- Removes clean_empty_library_items functionality that incorrectly deleted critical paths (e.g., Postgres data, Steam locks)
- Cleans up associated tests and unnecessary protection rules
- Ensures empty folders are preserved by default for safety
2026-01-15 21:24:38 +08:00
Tw93
c2eb73b213 fix: correct pnpm store default path
- Change pnpm store path from incorrect ~/.pnpm-store to correct ~/Library/pnpm/store
- The default pnpm store location on macOS is ~/Library/pnpm/store
- Fixes #319
2026-01-15 21:04:54 +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
30547c9c4c refactor(uninstall): enhance login item removal and brew UI
- Escape quotes/backslashes in app names for AppleScript safety
- Silence osascript stdout to prevent output noise
- Capture brew uninstall output to avoid spinner corruption
- Log brew errors to debug_log for troubleshooting
2026-01-15 15:13:51 +08:00
Tw93
9a9e6c780f Merge pull request #318 from NanmiCoder/main
fix: resolve password input issue with special characters
2026-01-15 14:34:25 +08:00
Tw93
7b14a3abd8 feat(uninstall): enhance brew UX and auto-cleanup dependencies
- Auto-run 'brew autoremove' after uninstalling casks
- Fix spinner interference during brew operations
- Add safety check for cask token detection
2026-01-15 14:31:36 +08:00
Tw93
dbf036fdaa refactor: simplify brew.sh with native macOS tools
- resolve_path: use realpath (macOS 12.3+) instead of python3/perl
- deduplicate tokens with sort -u instead of manual loop
- reuse _extract_cask_token_from_path in symlink check
- simplify brew_uninstall_cask boolean logic

Reduces 88 lines (281 → 193)
2026-01-15 14:05:42 +08:00
Tw93
3b517c7a6b Merge branch 'dev' into fix/harden-brew-uninstall 2026-01-15 14:00:20 +08:00
程序员阿江(Relakkes)
f8cb96d328 fix: resolve password input issue with special characters
Remove -icanon mode from stty settings to fix password authentication
failures when passwords contain special characters like '.' or '@'.

The non-canonical mode (-icanon min 1 time 0) caused character loss
in Terminal.app. Using only -echo keeps canonical mode which provides
more reliable character handling across all terminal emulators.
2026-01-15 13:29:35 +08:00
Tw93
518b57024c chore: auto format code 2026-01-15 03:42:35 +00:00
Tw93
318c67ffbe perf: optimize search filter rendering in paginated menu
- Use partial redraw for search input updates instead of full screen refresh
- Reduces flickering when typing in the filter box
- Improve responsiveness of search interaction
2026-01-15 11:41:16 +08:00
Tw93
9e1d09cb93 fix: handle spaces in dock item removal
- URL-encode paths when matching against Dock persistent-apps
- Fixes issue where apps with spaces in names (e.g. 'Clash Party') were not removed from Dock
2026-01-15 11:40:49 +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
Tw93
cac2909093 fix: prevent Microsoft Teams from being misdetected as Edge
Fixes #313

Change browser process detection from pgrep -f (full command line match)
to pgrep -x (exact process name match) to prevent false positives.

Microsoft Teams processes contain 'Microsoft' in their paths and may have
Chromium-based components, which was causing them to be incorrectly
identified as Microsoft Edge during clean operations.

Changes:
- Chrome detection: pgrep -f → pgrep -x
- Edge detection: pgrep -f → pgrep -x
- Edge updater detection: pgrep -f → pgrep -x

This approach is consistent with Firefox detection and prevents Apps like
Microsoft Teams, Microsoft Office, or other Microsoft products from
triggering false Edge detection.

All existing tests pass (9/9 in clean_browser_versions.bats).
2026-01-15 09:51:56 +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
Jack Phallen
d884a268e8 fix(uninstall): Harden brew uninstall 2026-01-14 09:17:41 -05:00
Tw93
d0faaa33c6 chore: auto format code 2026-01-14 06:10:25 +00:00
Tw93
62cfafd7da Tighten dock removal and add brew uninstall fallback 2026-01-14 14:09:08 +08:00
Tw93
572c5c7b3b chore: auto format code 2026-01-14 05:01:12 +00:00
Tw93
a800e9e48f Merge branch 'main' of github.com:tw93/Mole 2026-01-14 12:56:54 +08:00
Tw93
8a873c85a3 fix: remove unsafe file cleanup in Library root and fix tests
- lib/clean: remove empty file cleanup in ~/Library to protect potential sentinel files
- tests: fix unbound variable error in clean_user_core.bats by initializing WHITELIST_PATTERNS
2026-01-14 12:56:38 +08: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
c210aad3a3 Merge branch 'dev' into dev 2026-01-14 10:18:21 +08:00
Tw93
83dc59bb54 feat: improve purge display with full paths and size sorting (#311)
- Show full project paths (~/www/project) instead of just project names
  - Sort artifacts by size descending (largest first)
  - Increase path display width for better readability
  - Support CMD+Click to open folders in terminal
2026-01-14 10:15:58 +08:00
Tw93
7360f0a59e feat: Implement empty file cleanup in ~/Library root (#234)
- Add logic to remove 0-byte files in ~/Library (maxdepth 1)
- Explicitly protect .localized files to preserve Finder localization
- Respect global whitelist patterns
2026-01-14 09:49:47 +08:00
Copper-Eye
fae1c88fa2 add cpu temp display and optimize user check 2026-01-13 17:21:03 -04:00
Tw93
421cdd09dc feat: enhance safe cache cleaning for Electron apps and VS Code
- Add safe cleanup for Antigravity, Filo, and Claude caches in Application Support (Cache, GPUCache, Code Cache only).
- Enhance VS Code cleanup to include deep rendering caches (GPU, Dawn) and extension installers.
- Validated to ensure no user data or pnpm/yarn executables are touched.
2026-01-13 19:04:54 +08:00
Tw93
8ec7663a70 Fixed the ShellCheck warning 2026-01-13 16:54:10 +08:00
Tw93
0bd30955a2 feat: detect multiple NDK and Rust toolchain versions (#234)
Add report-only detection for multiple Android NDK and Rust toolchain
installations. Users receive helpful guidance for manual cleanup via
Android Studio SDK Manager or rustup commands.

- Add check_android_ndk() and check_rust_toolchains()
- Extract check_multiple_versions() helper (DRY)
- Add 4 test cases, optimize test performance
- Fix shellcheck warnings

All 393 tests passing.
2026-01-13 15:59:43 +08:00
Tw93
5b51007c3f Fix mo purge UI glitch by correctly clearing the scanning progress line without overwriting the title. 2026-01-13 14:16:41 +08:00
Tw93
3c8c2b3b98 chore: auto format code 2026-01-13 02:45:33 +00:00
Tw93
6b594c7d69 feat: add Homebrew integration and optimize UI performance
- Add Homebrew cask detection and use 'brew uninstall --cask' for proper cleanup
  - Add real-time progress feedback during uninstallation
  - Optimize scroll performance by only redrawing visible items
  - Replace Python-based Dock removal with PlistBuddy for better compatibility
  - Add comprehensive tests for Homebrew functionality

  Fixes #306
2026-01-13 10:44:48 +08:00
Tw93
8bd2bac580 Merge branch 'dev' 2026-01-12 17:50:07 +08:00
Tw93
5d77001a72 Optimize the effect and speed of scanning 2026-01-12 17:49:51 +08:00
Tw93
93dee7b94d Implemented safer temp cleanup and error reporting while fixing folded-directory size fallback to prevent double counting and aligning Homebrew cleanup traps with safe removal. 2026-01-12 15:45:31 +08:00
Tw93
5d5056fc9e fix: address mo update hanging and imporve temporary file reliability 2026-01-12 14:55:42 +08:00
Tw93
1a40875b80 refactor: improve code quality and test coverage
This commit addresses several code quality issues identified in the
recent bash 3.2 compatibility fixes:

1. Remove redundant array length check in is_whitelisted()
   - The second check for array length > 0 is unnecessary after
     already checking for length == 0

2. Clean up commented dangerous cleanup code in dev.sh
   - Replace commented-out code with clear documentation
   - Add explicit notes explaining why certain paths are excluded
   - Improves maintainability by preventing confusion

3. Enhance test coverage for excluded paths
   - Add tests to verify Mix archives are NOT cleaned
   - Add tests to verify Stack programs are NOT cleaned
   - Add tests to verify VS Code workspace storage is NOT cleaned
   - These tests ensure critical data remains protected

All changes pass ShellCheck, syntax validation, and formatting checks.
2026-01-12 10:09:02 +08:00