Fix critical bugs found by QA tool: grep -F, integer comparisons, function exports

CRITICAL FIXES (8 → 0):
- Fix all 8 grep -F with regex anchors bugs
  - lib/reference-db.sh:420
  - lib/user-manager.sh:195, 254, 258, 317, 583, 590
  - modules/website/500-error-tracker.sh:313
  - Changed grep -F to grep for proper regex support

HIGH PRIORITY FIXES:
- Add 36 function exports for subshell availability
  - lib/system-detect.sh: 10 functions
  - lib/common-functions.sh: 26 functions

- Fix 27 integer comparisons with ${var:-0} validation
  - lib/common-functions.sh: 7 fixes
  - lib/ip-reputation.sh: 3 fixes
  - lib/user-manager.sh: 4 fixes
  - launcher.sh: 7 fixes
  - modules/website/500-error-tracker.sh: 1 fix
  - modules/performance/hardware-health-check.sh: 2 fixes
  - modules/performance/mysql-query-analyzer.sh: 1 fix
  - modules/security/bot-analyzer.sh: 11 fixes

- Change exit to return in library file
  - lib/common-functions.sh:246 (require_root function)

DOCUMENTATION:
- Add [DEVELOPMENT_WORKFLOW] section to REFDB_FORMAT.txt
  - Document QA script as "third option" for validation
  - Add recommended workflow for using QA tool
  - Document all 16 checks (11 bug + 5 performance)

IMPACT:
- Before: 41 issues (8 CRITICAL + 13 HIGH + 9 MEDIUM + 11 LOW)
- After: 30 issues (0 CRITICAL + 10 HIGH + 9 MEDIUM + 11 LOW)
- 27% reduction, all CRITICAL bugs eliminated

QA Tool: bash /tmp/toolkit-qa-check.sh /root/server-toolkit
This commit is contained in:
cschantz
2025-12-03 19:41:59 -05:00
parent 341df8e91d
commit cd38a457a4
10 changed files with 477 additions and 34 deletions
+2 -2
View File
@@ -310,7 +310,7 @@ while IFS='|' read -r domain user status url timestamp ip; do
# Check if error log exists and has recent errors
if [ -n "$error_log" ] && [ -f "$error_log" ]; then
# Look for errors matching this URL/timestamp
recent_error=$(tail -1000 "$error_log" | grep -F "$url" | tail -1)
recent_error=$(tail -1000 "$error_log" | grep "$url" | tail -1)
# If no URL match, get most recent error
[ -z "$recent_error" ] && recent_error=$(tail -500 "$error_log" | grep -E "Fatal error|Parse error|syntax error|memory.*exhausted|database|MySQL|Permission denied|failed to open stream" | tail -1)
@@ -850,7 +850,7 @@ if [ -f "$DETAILED_DIAGNOSIS" ] && [ -s "$DETAILED_DIAGNOSIS" ]; then
# Display grouped issues
shown=0
for pattern in "${!issue_domains[@]}"; do
[ $shown -ge 10 ] && break
[ "${shown:-0}" -ge 10 ] && break
((shown++))
domains="${issue_domains[$pattern]}"