diff --git a/lib/reference-db.sh b/lib/reference-db.sh index d3e2196..8ad91c0 100755 --- a/lib/reference-db.sh +++ b/lib/reference-db.sh @@ -433,7 +433,7 @@ build_wordpress_section() { local db_host=$(grep "DB_HOST" "$wp_config" | grep -oP "'[^']+'" 2>/dev/null | tail -1 | tr -d "'" || true) # Try to get site URL from wp-config defines - local site_url=$(grep -E "WP_SITEURL|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"]+" || true) + local site_url=$(grep -E "WP_SITEURL|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"]+" 2>/dev/null || true) if [ -n "$site_url" ]; then domain="$site_url" fi diff --git a/lib/system-detect.sh b/lib/system-detect.sh index 5c7fbe4..4f4d15a 100755 --- a/lib/system-detect.sh +++ b/lib/system-detect.sh @@ -147,7 +147,7 @@ detect_web_server() { # Nginx if command_exists nginx; then SYS_WEB_SERVER="nginx" - SYS_WEB_SERVER_VERSION=$(nginx -v 2>&1 | grep -oP 'nginx/\K[\d.]+') + SYS_WEB_SERVER_VERSION=$(nginx -v 2>&1 | grep -oP 'nginx/\K[\d.]+' 2>/dev/null) print_success "Detected Nginx ${SYS_WEB_SERVER_VERSION}" return 0 fi diff --git a/lib/threat-intelligence.sh b/lib/threat-intelligence.sh index 3781f62..fef565b 100644 --- a/lib/threat-intelligence.sh +++ b/lib/threat-intelligence.sh @@ -51,10 +51,10 @@ check_abuseipdb() { -H "Accept: application/json" 2>/dev/null) if [ -n "$response" ]; then - local confidence=$(echo "$response" | grep -oP '"abuseConfidenceScore":\K[0-9]+' | head -1) - local reports=$(echo "$response" | grep -oP '"totalReports":\K[0-9]+' | head -1) - local country=$(echo "$response" | grep -oP '"countryCode":"\K[^"]+' | head -1) - local isp=$(echo "$response" | grep -oP '"isp":"\K[^"]+' | head -1) + local confidence=$(echo "$response" | grep -oP '"abuseConfidenceScore":\K[0-9]+' 2>/dev/null | head -1) + local reports=$(echo "$response" | grep -oP '"totalReports":\K[0-9]+' 2>/dev/null | head -1) + local country=$(echo "$response" | grep -oP '"countryCode":"\K[^"]+' 2>/dev/null | head -1) + local isp=$(echo "$response" | grep -oP '"isp":"\K[^"]+' 2>/dev/null | head -1) local result="${confidence:-0}|${reports:-0}|${country:-Unknown}|${isp:-Unknown}" echo "$result" | tee "$cache_file" diff --git a/modules/backup/acronis-agent-status.sh b/modules/backup/acronis-agent-status.sh index 93de47e..d7ed285 100755 --- a/modules/backup/acronis-agent-status.sh +++ b/modules/backup/acronis-agent-status.sh @@ -169,7 +169,7 @@ acronis_ports=$(netstat -tlnp 2>/dev/null | grep -E "(acronis|mms|aakore)" | awk if [ -n "$acronis_ports" ]; then echo "Active Acronis services:" echo "$acronis_ports" | while read -r addr process; do - port=$(echo "$addr" | grep -oP ':\K[0-9]+$') + port=$(echo "$addr" | grep -oP ':\K[0-9]+$' 2>/dev/null) if echo "$addr" | grep -q "127.0.0.1\|::1"; then # Local-only port if [ "$port" = "9850" ]; then diff --git a/modules/security/bot-analyzer.sh b/modules/security/bot-analyzer.sh index 238a7ab..bf5819a 100755 --- a/modules/security/bot-analyzer.sh +++ b/modules/security/bot-analyzer.sh @@ -2449,7 +2449,7 @@ show_detailed_recommendations() { awk -F'|' '$1 >= 70 {printf " • %s (score: %s)\n", $2, $1}' "$TEMP_DIR/threat_scores.txt" 2>/dev/null | head -10 ;; htaccess_domain) - local target_domain=$(echo "$action_title" | grep -oP 'to \K[^ ]+') + local target_domain=$(echo "$action_title" | grep -oP 'to \K[^ ]+' 2>/dev/null) echo "Target Domain: $target_domain" if [ -s "$TEMP_DIR/domain_threats_sorted.txt" ]; then grep "^$target_domain|" "$TEMP_DIR/domain_threats_sorted.txt" | while IFS='|' read -r domain total_req bot_req bot_pct high_risk attacks ips; do diff --git a/modules/website/500-error-tracker.sh b/modules/website/500-error-tracker.sh index e3a16c1..eb164c6 100755 --- a/modules/website/500-error-tracker.sh +++ b/modules/website/500-error-tracker.sh @@ -821,7 +821,7 @@ if [ -f "$DETAILED_DIAGNOSIS" ] && [ -s "$DETAILED_DIAGNOSIS" ]; then while IFS='|' read -r ctype full_diag; do # Extract just the error part (after domain/) issue_pattern=$(echo "$full_diag" | sed 's/^[^ ]* - //') - domain_part=$(echo "$full_diag" | grep -oP '^[^/]+') + domain_part=$(echo "$full_diag" | grep -oP '^[^/]+' 2>/dev/null) # Append to temporary storage pattern_domains_temp[$issue_pattern]+="$domain_part"$'\n'