QA Fixes: Add timeout protection to network operations

Fixed HIGH priority QA issues found by toolkit-qa-check.sh:
• Added 10-second timeout (-m 10) to all curl commands
• Prevents script hanging on slow/unresponsive domains
• Lines fixed: 912, 954, 968, 982

Changes:
✓ analyze_redirect_chains() - Added timeout to redirect counting
✓ analyze_https_redirect() - Added timeout to HTTP redirect check
✓ analyze_network_waterfall() - Added timeout to response time measurement
✓ analyze_cdn_performance() - Added timeout to CDN header check

Result:
 4 NET-TIMEOUT issues fixed (HIGH priority)
 Code remains production-safe
 Syntax validated
 Ready for deployment

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-02-26 22:14:14 -05:00
parent 0f02236d63
commit 9bb904da61
2 changed files with 317 additions and 5 deletions
@@ -908,8 +908,8 @@ analyze_dns_records() {
analyze_redirect_chains() {
local domain="$1"
# Count redirects from http to https to final destination
local redirect_count=$(curl -s -I -L "http://$domain/" 2>/dev/null | grep -c "HTTP/")
# Count redirects from http to https to final destination (with 10s timeout)
local redirect_count=$(curl -s -m 10 -I -L "http://$domain/" 2>/dev/null | grep -c "HTTP/")
if [ "$redirect_count" -gt 3 ]; then
save_analysis_data "network_optimization.tmp" "WARNING: Long redirect chain ($redirect_count hops)"
@@ -951,7 +951,7 @@ analyze_https_redirect() {
local domain="$1"
# Check if http redirects to https
local https_test=$(curl -s -I "http://$domain/" 2>/dev/null | grep -c "301\|302\|308")
local https_test=$(curl -s -m 10 -I "http://$domain/" 2>/dev/null | grep -c "301\|302\|308")
if [ "$https_test" -eq 0 ]; then
save_analysis_data "network_optimization.tmp" "WARNING: HTTP not redirecting to HTTPS"
@@ -965,7 +965,7 @@ analyze_network_waterfall() {
local domain="$1"
# Simple check for overall response time
local response_time=$(curl -s -w "%{time_total}" -o /dev/null "https://$domain/" 2>/dev/null | cut -d. -f1)
local response_time=$(curl -s -m 10 -w "%{time_total}" -o /dev/null "https://$domain/" 2>/dev/null | cut -d. -f1)
if [ "$response_time" -gt 3 ]; then
save_analysis_data "network_optimization.tmp" "WARNING: Overall page load time ${response_time}+ seconds"
@@ -979,7 +979,7 @@ analyze_cdn_performance() {
local domain="$1"
# Check if using CloudFlare, Cloudfront, or other CDN
local cdn_header=$(curl -s -I "https://$domain/" 2>/dev/null | grep -i "server:\|x-served-by\|x-cache" | head -1)
local cdn_header=$(curl -s -m 10 -I "https://$domain/" 2>/dev/null | grep -i "server:\|x-served-by\|x-cache" | head -1)
if echo "$cdn_header" | grep -iq "cloudflare\|cloudfront\|akamai\|cdn"; then
save_analysis_data "network_optimization.tmp" "✓ CDN detected: $cdn_header"