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

chore: auto format code

This commit is contained in:
Tw93
2025-12-25 03:27:51 +00:00
parent 952b2eea61
commit 4aaab78985

View File

@@ -15,19 +15,22 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Directories that typically contain user-customized configurations, themes, # Directories that typically contain user-customized configurations, themes,
# or personal data that users might want to backup before uninstalling # or personal data that users might want to backup before uninstalling
readonly SENSITIVE_DATA_PATTERNS=( readonly SENSITIVE_DATA_PATTERNS=(
"\.warp" # Warp terminal configs/themes "\.warp" # Warp terminal configs/themes
"/\.config/" # Standard Unix config directory "/\.config/" # Standard Unix config directory
"/themes/" # Theme customizations "/themes/" # Theme customizations
"/settings/" # Settings directories "/settings/" # Settings directories
"/Application Support/[^/]+/User Data" # Chrome/Electron user data "/Application Support/[^/]+/User Data" # Chrome/Electron user data
"/Preferences/[^/]+\.plist" # User preference files "/Preferences/[^/]+\.plist" # User preference files
"/Documents/" # User documents "/Documents/" # User documents
"/\.ssh/" # SSH keys and configs (critical) "/\.ssh/" # SSH keys and configs (critical)
"/\.gnupg/" # GPG keys (critical) "/\.gnupg/" # GPG keys (critical)
) )
# Join patterns into a single regex for grep # Join patterns into a single regex for grep
SENSITIVE_DATA_REGEX=$(IFS='|'; echo "${SENSITIVE_DATA_PATTERNS[*]}") SENSITIVE_DATA_REGEX=$(
IFS='|'
echo "${SENSITIVE_DATA_PATTERNS[*]}"
)
# Decode and validate base64 encoded file list # Decode and validate base64 encoded file list
# Returns decoded string if valid, empty string otherwise # Returns decoded string if valid, empty string otherwise
@@ -44,7 +47,7 @@ decode_file_list() {
if ! decoded=$(printf '%s' "$encoded" | base64 -d 2> /dev/null); then if ! decoded=$(printf '%s' "$encoded" | base64 -d 2> /dev/null); then
log_error "Failed to decode file list for $app_name" >&2 log_error "Failed to decode file list for $app_name" >&2
echo "" echo ""
return 0 # Return success with empty string return 0 # Return success with empty string
fi fi
fi fi
@@ -52,7 +55,7 @@ decode_file_list() {
if [[ "$decoded" =~ $'\0' ]]; then if [[ "$decoded" =~ $'\0' ]]; then
log_warning "File list for $app_name contains null bytes, rejecting" >&2 log_warning "File list for $app_name contains null bytes, rejecting" >&2
echo "" echo ""
return 0 # Return success with empty string return 0 # Return success with empty string
fi fi
# Validate paths look reasonable (each line should be a path or empty) # Validate paths look reasonable (each line should be a path or empty)
@@ -60,7 +63,7 @@ decode_file_list() {
if [[ -n "$line" && ! "$line" =~ ^/ ]]; then if [[ -n "$line" && ! "$line" =~ ^/ ]]; then
log_warning "Invalid path in file list for $app_name: $line" >&2 log_warning "Invalid path in file list for $app_name: $line" >&2
echo "" echo ""
return 0 # Return success with empty string return 0 # Return success with empty string
fi fi
done <<< "$decoded" done <<< "$decoded"
@@ -171,9 +174,9 @@ batch_uninstall_applications() {
local needs_sudo=false local needs_sudo=false
local app_owner=$(get_file_owner "$app_path") local app_owner=$(get_file_owner "$app_path")
local current_user=$(whoami) local current_user=$(whoami)
if [[ ! -w "$(dirname "$app_path")" ]] || \ if [[ ! -w "$(dirname "$app_path")" ]] ||
[[ "$app_owner" == "root" ]] || \ [[ "$app_owner" == "root" ]] ||
[[ -n "$app_owner" && "$app_owner" != "$current_user" ]]; then [[ -n "$app_owner" && "$app_owner" != "$current_user" ]]; then
needs_sudo=true needs_sudo=true
fi fi
@@ -401,7 +404,7 @@ batch_uninstall_applications() {
# These are often missed by standard cleanup tools # These are often missed by standard cleanup tools
# Format: ~/Library/Preferences/ByHost/com.app.id.XXXX.plist # Format: ~/Library/Preferences/ByHost/com.app.id.XXXX.plist
if [[ -d ~/Library/Preferences/ByHost ]]; then if [[ -d ~/Library/Preferences/ByHost ]]; then
find ~/Library/Preferences/ByHost -maxdepth 1 -name "${bundle_id}.*.plist" -delete 2>/dev/null || true find ~/Library/Preferences/ByHost -maxdepth 1 -name "${bundle_id}.*.plist" -delete 2> /dev/null || true
fi fi
fi fi