1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 19:40:07 +00:00

fix(appli-support):using whitelist in application_support clean (#562)

* fix(appli-support):using whitelist in application_support clean

* fix: harden clash verge app support protection

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
This commit is contained in:
2026-03-13 11:38:37 +08:00
committed by GitHub
parent e642817b1f
commit c5d923cd48
4 changed files with 48 additions and 2 deletions

View File

@@ -860,7 +860,11 @@ clean_application_support_logs() {
local app_name_lower
app_name_lower=$(echo "$app_name" | LC_ALL=C tr '[:upper:]' '[:lower:]')
local is_protected=false
if should_protect_data "$app_name"; then
if is_path_whitelisted "$app_dir" 2> /dev/null; then
is_protected=true
elif should_protect_path "$app_dir" 2> /dev/null; then
is_protected=true
elif should_protect_data "$app_name"; then
is_protected=true
elif should_protect_data "$app_name_lower"; then
is_protected=true
@@ -874,6 +878,9 @@ clean_application_support_logs() {
local -a start_candidates=("$app_dir/log" "$app_dir/logs" "$app_dir/activitylog" "$app_dir/Cache/Cache_Data" "$app_dir/Crashpad/completed")
for candidate in "${start_candidates[@]}"; do
if [[ -d "$candidate" ]]; then
if should_protect_path "$candidate" 2> /dev/null || is_path_whitelisted "$candidate" 2> /dev/null; then
continue
fi
# Quick count check - skip if too many items to avoid hanging
local quick_count
quick_count=$(app_support_entry_count_capped "$candidate" 1 101)
@@ -901,6 +908,9 @@ clean_application_support_logs() {
local candidate_item_count=0
while IFS= read -r -d '' item; do
[[ -e "$item" ]] || continue
if should_protect_path "$item" 2> /dev/null || is_path_whitelisted "$item" 2> /dev/null; then
continue
fi
item_found=true
candidate_item_count=$((candidate_item_count + 1))
if [[ ! -L "$item" && (-f "$item" || -d "$item") ]]; then

View File

@@ -290,6 +290,8 @@ readonly DATA_PROTECTED_BUNDLES=(
"clash.*"
"Clash.*"
"clash_*"
"*clash-verge*"
"*Clash-Verge*"
"clashverge*"
"ClashVerge*"
"com.nssurge.surge-mac"
@@ -694,7 +696,7 @@ should_protect_data() {
com.nssurge.* | com.v2ray.* | com.clash.* | ClashX* | Surge* | Shadowrocket* | Quantumult*)
return 0
;;
clash-* | Clash-* | *-clash | *-Clash | clash.* | Clash.* | clash_* | clashverge* | ClashVerge*)
clash-* | Clash-* | *-clash | *-Clash | clash.* | Clash.* | clash_* | *clash-verge* | *Clash-Verge* | clashverge* | ClashVerge*)
return 0
;;
com.docker.* | com.getpostman.* | com.insomnia.*)