cschantz
c5472674a1
Add parameter validation to 6 more functions + QA improvements
...
PARAMETER VALIDATION FIXES (6 functions):
1. lib/common-functions.sh:219 - format_duration()
2. lib/php-detector.sh:277 - get_fpm_process_count()
3. lib/user-manager.sh:263 - get_plesk_user_domains()
4. modules/performance/hardware-health-check.sh:44 - add_finding()
5. modules/performance/hardware-health-check.sh:55 - command_exists()
6. modules/performance/network-bandwidth-analyzer.sh:45 - add_finding()
7. modules/performance/network-bandwidth-analyzer.sh:56 - command_exists()
All functions now validate required parameters with:
- [ -z "$1" ] && return 1 (single param)
- [ -z "$1" ] || [ -z "$2" ] && return 1 (multiple params)
QA SCRIPT IMPROVEMENTS:
- tools/toolkit-qa-check.sh: Skip $@ / $* passthrough functions
- Added filter for echo/printf functions using only $@ or $*
- Example: cecho() { echo -e "$@" }
- These don't need validation as they passthrough all args
PROGRESS:
- HIGH issues remain at 10 (different ones now)
- Eliminated more false positives
- Next: Fix remaining issues in bot-analyzer.sh
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 16:42:46 -05:00
cschantz
52dcadea46
Fix 3 HIGH issues with parameter validation + QA improvements
...
PARAMETER VALIDATION FIXES (3 functions):
1. lib/common-functions.sh:238 - command_exists()
- Added [ -z "$1" ] && return 1
2. lib/php-detector.sh:284 - get_fpm_memory_usage()
- Added [ -z "$1" ] && return 1
3. lib/user-manager.sh:271 - get_interworx_user_domains()
- Added [ -z "$1" ] && return 1
QA SCRIPT IMPROVEMENTS:
- tools/toolkit-qa-check.sh: Filter out AWK/sed field references
- Problem: $1 in awk '{print $1}' was detected as bash parameter
- Solution: grep -v 'awk\|sed' before checking for $1-9
- Impact: Eliminates 7 false positives from functions with no params
FALSE POSITIVES ELIMINATED:
- is_server_stressed() - $1 was from awk command
- calculate_server_memory_capacity() - $2 was from awk command
- calculate_balanced_memory_allocation() - $2 was from awk command
- list_cpanel_users() - no parameters
- list_interworx_users() - no parameters
- list_system_users() - no parameters
- press_enter() - $1 was from neighboring function
IMPACT:
HIGH issues: 10 → 10 (fixed 3, eliminated 7 FPs, but 10 new remain)
Need to improve QA script further to extract exact function bodies
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 16:41:03 -05:00
cschantz
9f9c68d542
Fix 9 MEDIUM hardcoded /var/cpanel paths - ALL MEDIUM ISSUES RESOLVED!
...
FIXES:
Changed hardcoded /var/cpanel paths to use environment variables with fallbacks:
reference-db.sh:
- Line 255: /var/cpanel/userdata → ${SYS_CPANEL_USERDATA_DIR:-/var/cpanel/userdata}
- Line 265: /var/cpanel/userdata → ${SYS_CPANEL_USERDATA_DIR:-/var/cpanel/userdata}
php-detector.sh:
- Line 69: /var/cpanel/userdata → ${SYS_CPANEL_USERDATA_DIR:-/var/cpanel/userdata}
user-manager.sh:
- Line 44-45: /var/cpanel/users → ${SYS_CPANEL_USERS_DIR:-/var/cpanel/users}
- Line 111: /var/cpanel/users → ${SYS_CPANEL_USERS_DIR:-/var/cpanel/users}
diagnostic-report.sh:
- Line 68: /var/cpanel/users → ${SYS_CPANEL_USERS_DIR:-/var/cpanel/users}
wordpress-cron-manager.sh:
- Line 229-230: /var/cpanel/userdata → ${SYS_CPANEL_USERDATA_DIR:-/var/cpanel/userdata}
IMPACT:
- Paths now configurable via environment variables
- Maintains backward compatibility with default paths
- Better multi-panel support flexibility
- More testable code (can override paths in tests)
QA STATUS:
🎉 ALL MEDIUM ISSUES RESOLVED! 🎉
- CRITICAL: 0 ✓
- HIGH: 0 ✓
- MEDIUM: 0 ✓
- LOW: 11 (remaining)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-03 20:19:43 -05:00
cschantz
6327ed7fe6
CRITICAL: Fix PHP-FPM pool detection - search by domain name not username
...
Problem:
- find_fpm_pool_config() only searched for $username.conf
- cPanel EA-PHP names pool configs as $domain.conf
- Example: pickledperil.com.conf NOT pickledperil.conf
- Result: 'No PHP-FPM pools found' error
Fix:
- Modified find_fpm_pool_config() to try domain-based naming first
- Falls back to username-based naming for compatibility
- Search order: domain → username
- Applies to all control panels (cPanel, Plesk, InterWorx)
Impact:
- PHP-FPM pools now detected correctly
- Memory capacity analysis now works
- All pool-based features functional
Test:
- find_fpm_pool_config('pickledperil', 'pickledperil.com')
- Returns: /opt/cpanel/ea-php81/root/etc/php-fpm.d/pickledperil.com.conf
2025-12-03 01:15:04 -05:00
cschantz
4e49776a35
Fix SCRIPT_DIR variable collision in PHP libraries
...
CRITICAL BUG FIX:
Problem: php-detector.sh and php-analyzer.sh were setting SCRIPT_DIR
which collided with parent script's SCRIPT_DIR variable causing
/lib/lib/ double path bug when sourcing libraries.
Solution:
- Changed SCRIPT_DIR to _LIB_DIR in both php-detector.sh and php-analyzer.sh
- Changed exit 1 to return 1 in sourced libraries (exit kills parent script)
Files modified:
- lib/php-detector.sh: Use _LIB_DIR instead of SCRIPT_DIR
- lib/php-analyzer.sh: Use _LIB_DIR instead of SCRIPT_DIR, return instead of exit
This prevents variable collision when libraries are sourced by modules.
2025-12-03 00:52:44 -05:00