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

Automated test synchronous update

This commit is contained in:
Tw93
2025-11-29 23:14:46 +09:00
parent a184094f45
commit 3f9d1205fd
10 changed files with 20 additions and 175 deletions

View File

@@ -40,7 +40,8 @@ clean_deep_system() {
local updates_cleaned=0
while IFS= read -r -d '' item; do
# Skip system-protected files (restricted flag)
local item_flags=$(ls -lO "$item" 2> /dev/null | awk '{print $5}')
local item_flags
item_flags=$(stat -f%Sf "$item" 2> /dev/null || echo "")
if [[ "$item_flags" == *"restricted"* ]]; then
continue
fi

View File

@@ -234,7 +234,7 @@ clean_application_support_logs() {
# Clean stale update downloads (older than 7 days)
if [[ -d "$app_dir/update" ]] && ls "$app_dir/update" > /dev/null 2>&1; then
while IFS= read -r update_dir; do
local dir_age_days=$(( ($(date +%s) - $(get_file_mtime "$update_dir")) / 86400 ))
local dir_age_days=$((($(date +%s) - $(get_file_mtime "$update_dir")) / 86400))
if [[ $dir_age_days -ge $MOLE_TEMP_FILE_AGE_DAYS ]]; then
safe_clean "$update_dir" "Stale update: $app_name"
fi

View File

@@ -36,14 +36,14 @@ readonly ICON_NAV_LEFT="←"
readonly ICON_NAV_RIGHT="→"
# Global configuration constants
readonly MOLE_TEMP_FILE_AGE_DAYS=7 # Temp file cleanup threshold
readonly MOLE_ORPHAN_AGE_DAYS=60 # Orphaned data threshold
readonly MOLE_MAX_PARALLEL_JOBS=15 # Parallel job limit
readonly MOLE_MAIL_DOWNLOADS_MIN_KB=5120 # Mail attachments size threshold (~5MB)
readonly MOLE_LOG_AGE_DAYS=30 # System log retention
readonly MOLE_CRASH_REPORT_AGE_DAYS=30 # Crash report retention
readonly MOLE_SAVED_STATE_AGE_DAYS=7 # App saved state retention
readonly MOLE_TM_BACKUP_SAFE_HOURS=48 # Time Machine failed backup safety window
readonly MOLE_TEMP_FILE_AGE_DAYS=7 # Temp file cleanup threshold
readonly MOLE_ORPHAN_AGE_DAYS=60 # Orphaned data threshold
readonly MOLE_MAX_PARALLEL_JOBS=15 # Parallel job limit
readonly MOLE_MAIL_DOWNLOADS_MIN_KB=5120 # Mail attachments size threshold (~5MB)
readonly MOLE_LOG_AGE_DAYS=30 # System log retention
readonly MOLE_CRASH_REPORT_AGE_DAYS=30 # Crash report retention
readonly MOLE_SAVED_STATE_AGE_DAYS=7 # App saved state retention
readonly MOLE_TM_BACKUP_SAFE_HOURS=48 # Time Machine failed backup safety window
# Get spinner characters (overridable via MO_SPINNER_CHARS)
mo_spinner_chars() {
@@ -91,6 +91,12 @@ validate_path_for_deletion() {
return 1
fi
# Check for path traversal attempts
if [[ "$path" =~ \.\. ]]; then
log_error "Path validation failed: path traversal not allowed: $path"
return 1
fi
# Check path doesn't contain dangerous characters
if [[ "$path" =~ [[:cntrl:]] ]] || [[ "$path" =~ $'\n' ]]; then
log_error "Path validation failed: contains control characters: $path"
@@ -99,7 +105,7 @@ validate_path_for_deletion() {
# Check path isn't critical system directory
case "$path" in
/ | /bin | /sbin | /usr | /usr/bin | /usr/sbin | /etc | /var | /System | /Library/Extensions)
/ | /bin | /sbin | /usr | /usr/bin | /usr/sbin | /etc | /var | /System | /System/* | /Library/Extensions)
log_error "Path validation failed: critical system directory: $path"
return 1
;;