Fix NULL check issues (5 HIGH issues resolved)
Added proper null/empty checks and variable quoting in 3 files: 1. wordpress-cron-manager.sh (2 issues): - Added validation for $site_path before use - Quoted variable in cron command to prevent word splitting - Lines 446-449: Check if path is empty or invalid before processing 2. malware-scanner.sh (1 issue): - Added safety check for $SCAN_DIR before suggesting rm -rf command - Prevents dangerous rm operations if variable is empty or root - Line 1583-1585: Guard against accidental deletions 3. mysql-restore-to-sql.sh (2 issues): - Quoted $datadir in echo statements showing manual commands - Lines 426, 441, 444, 447: Proper quoting in examples Impact: Prevents potential issues from empty/undefined variables
This commit is contained in:
@@ -442,6 +442,12 @@ case "$choice" in
|
||||
count=$((count + 1))
|
||||
site_path=$(dirname "$wp_config")
|
||||
|
||||
# Validate site path
|
||||
if [ -z "$site_path" ] || [ ! -d "$site_path" ]; then
|
||||
echo -e "${YELLOW}Warning: Invalid site path${NC}"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}Site $count:${NC} $site_path"
|
||||
|
||||
# Backup
|
||||
@@ -458,7 +464,7 @@ case "$choice" in
|
||||
fi
|
||||
|
||||
# Add cron job with staggered timing
|
||||
cron_cmd="cd $site_path && /usr/bin/php -q wp-cron.php >/dev/null 2>&1"
|
||||
cron_cmd="cd \"$site_path\" && /usr/bin/php -q wp-cron.php >/dev/null 2>&1"
|
||||
|
||||
if ! crontab -u "$target_user" -l 2>/dev/null | grep -q "$site_path.*wp-cron.php"; then
|
||||
cron_time=$(generate_staggered_cron)
|
||||
@@ -545,7 +551,7 @@ case "$choice" in
|
||||
fi
|
||||
|
||||
# Add cron job with staggered timing
|
||||
cron_cmd="cd $site_path && /usr/bin/php -q wp-cron.php >/dev/null 2>&1"
|
||||
cron_cmd="cd \"$site_path\" && /usr/bin/php -q wp-cron.php >/dev/null 2>&1"
|
||||
|
||||
if ! crontab -u "$user" -l 2>/dev/null | grep -q "$site_path.*wp-cron.php"; then
|
||||
cron_time=$(generate_staggered_cron)
|
||||
|
||||
Reference in New Issue
Block a user