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 831ef9eaf4
commit 86ed92e9e2
10 changed files with 477 additions and 34 deletions
+7 -7
View File
@@ -85,7 +85,7 @@ run_module() {
local exit_code=$?
echo ""
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
if [ $exit_code -eq 0 ]; then
if [ "${exit_code:-0}" -eq 0 ]; then
echo -e "${GREEN}✓ Completed successfully${NC}"
else
echo -e "${RED}✗ Exited with code: $exit_code${NC}"
@@ -716,42 +716,42 @@ cleanup_all_data() {
# Remove temp session directories
local temp_count=$(find /tmp -maxdepth 1 -name "server-toolkit-*" -type d 2>/dev/null | wc -l)
if [ $temp_count -gt 0 ]; then
if [ "${temp_count:-0}" -gt 0 ]; then
find /tmp -maxdepth 1 -name "server-toolkit-*" -type d -exec rm -rf {} \; 2>/dev/null
print_success "Removed $temp_count temporary session directories"
fi
# Remove bot analyzer reports
local bot_reports=$(find /tmp -maxdepth 1 -name "bot_analysis_*" 2>/dev/null | wc -l)
if [ $bot_reports -gt 0 ]; then
if [ "${bot_reports:-0}" -gt 0 ]; then
find /tmp -maxdepth 1 -name "bot_analysis_*" -exec rm -f {} \; 2>/dev/null
print_success "Removed $bot_reports bot analysis reports"
fi
# Remove MySQL analysis reports
local mysql_reports=$(find /tmp -maxdepth 1 -name "mysql_analysis_*" 2>/dev/null | wc -l)
if [ $mysql_reports -gt 0 ]; then
if [ "${mysql_reports:-0}" -gt 0 ]; then
find /tmp -maxdepth 1 -name "mysql_analysis_*" -exec rm -f {} \; 2>/dev/null
print_success "Removed $mysql_reports MySQL analysis reports"
fi
# Remove system health reports
local health_reports=$(find /tmp -maxdepth 1 -name "system_health_report_*" 2>/dev/null | wc -l)
if [ $health_reports -gt 0 ]; then
if [ "${health_reports:-0}" -gt 0 ]; then
find /tmp -maxdepth 1 -name "system_health_report_*" -exec rm -f {} \; 2>/dev/null
print_success "Removed $health_reports system health reports"
fi
# Remove network bandwidth reports
local network_reports=$(find /tmp -maxdepth 1 -name "network_bandwidth_report_*" 2>/dev/null | wc -l)
if [ $network_reports -gt 0 ]; then
if [ "${network_reports:-0}" -gt 0 ]; then
find /tmp -maxdepth 1 -name "network_bandwidth_report_*" -exec rm -f {} \; 2>/dev/null
print_success "Removed $network_reports network bandwidth reports"
fi
# Remove hardware health reports
local hardware_reports=$(find /tmp -maxdepth 1 -name "hardware_health_report_*" 2>/dev/null | wc -l)
if [ $hardware_reports -gt 0 ]; then
if [ "${hardware_reports:-0}" -gt 0 ]; then
find /tmp -maxdepth 1 -name "hardware_health_report_*" -exec rm -f {} \; 2>/dev/null
print_success "Removed $hardware_reports hardware health reports"
fi