1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 15:45:06 +00:00

Enhance the protection of the Clash system.

This commit is contained in:
Tw93
2025-11-16 13:38:16 +08:00
parent 42fa619c5d
commit a1e2958b64
3 changed files with 20 additions and 4 deletions

View File

@@ -34,8 +34,6 @@ declare -a DEFAULT_WHITELIST_PATTERNS=(
"$HOME/.cache/huggingface*" "$HOME/.cache/huggingface*"
"$HOME/.m2/repository/*" "$HOME/.m2/repository/*"
"$HOME/.ollama/models/*" "$HOME/.ollama/models/*"
"$HOME/Library/Caches/com.nssurge.surge-mac/*"
"$HOME/Library/Application Support/com.nssurge.surge-mac/*"
) )
declare -a WHITELIST_PATTERNS=() declare -a WHITELIST_PATTERNS=()
WHITELIST_WARNINGS=() WHITELIST_WARNINGS=()
@@ -241,6 +239,18 @@ safe_clean() {
local -a existing_paths=() local -a existing_paths=()
for path in "${targets[@]}"; do for path in "${targets[@]}"; do
local skip=false local skip=false
# Hard-coded protection for critical apps (cannot be disabled by user)
case "$path" in
*clash*|*Clash*|*surge*|*Surge*|*mihomo*)
skip=true
((skipped_count++))
;;
esac
[[ "$skip" == "true" ]] && continue
# Check user-defined whitelist
if [[ ${#WHITELIST_PATTERNS[@]} -gt 0 ]]; then if [[ ${#WHITELIST_PATTERNS[@]} -gt 0 ]]; then
for w in "${WHITELIST_PATTERNS[@]}"; do for w in "${WHITELIST_PATTERNS[@]}"; do
# Match both exact path and glob pattern # Match both exact path and glob pattern
@@ -1201,7 +1211,7 @@ perform_cleanup() {
# Skip system and protected apps # Skip system and protected apps
case "$app_name" in case "$app_name" in
com.apple.* | Adobe* | 1Password | Claude) com.apple.* | Adobe* | 1Password | Claude | *ClashX* | *clash* | mihomo* | *Surge*)
continue continue
;; ;;
esac esac

View File

@@ -1269,6 +1269,12 @@ readonly DATA_PROTECTED_BUNDLES=(
"com.telerik.Fiddler" # Fiddler "com.telerik.Fiddler" # Fiddler
"com.usebruno.app" # Bruno (API client) "com.usebruno.app" # Bruno (API client)
# Network Proxy & VPN Tools (protect all variants)
"*clash*" # All Clash variants (ClashX, ClashX Pro, Clash Verge, etc)
"*Clash*" # Capitalized variants
"com.nssurge.surge-mac" # Surge
"mihomo*" # Mihomo Party and variants
# ============================================================================ # ============================================================================
# Development Tools - Git & Version Control # Development Tools - Git & Version Control
# ============================================================================ # ============================================================================

2
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh" source "$SCRIPT_DIR/lib/common.sh"
# Version info # Version info
VERSION="1.9.6" VERSION="1.9.7"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Get latest version from remote repository # Get latest version from remote repository