CRITICAL FIX: Add explicit function validation and error checking to show_scan_menu
FIXED: - Added explicit validation that show_scan_menu() function exists before calling - Added explicit validation that print_banner() exists before using it - Added error output if print_banner() call fails - Improved handling of empty available_scanners array (display '(None currently installed)') - Added error checking to ensure functions are available before use BEHAVIOR CHANGE: - Menu now validates dependencies before displaying - Better error messages if required functions are missing - More robust handling of library sourcing failures This should fix the issue where menu fails to display when libraries are not properly sourced.
This commit is contained in:
@@ -2227,20 +2227,33 @@ delete_standalone_sessions() {
|
||||
|
||||
# Main scan menu
|
||||
show_scan_menu() {
|
||||
# Ensure print_banner is available before calling it
|
||||
if ! declare -f "print_banner" &>/dev/null; then
|
||||
echo "ERROR: print_banner function not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Build reference database once for the entire menu session
|
||||
if command -v build_reference_database &>/dev/null; then
|
||||
echo "Building system reference database..."
|
||||
build_reference_database 2>/dev/null || true
|
||||
clear
|
||||
fi
|
||||
|
||||
while true; do
|
||||
print_banner "Malware Scanner"
|
||||
# Call print_banner - MUST succeed
|
||||
print_banner "Malware Scanner" || {
|
||||
echo "ERROR: print_banner failed" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "Available Scanners:"
|
||||
for scanner in "${available_scanners[@]}"; do
|
||||
echo " • ${scanner^}"
|
||||
done
|
||||
if [ ${#available_scanners[@]} -eq 0 ]; then
|
||||
echo " (None currently installed)"
|
||||
else
|
||||
for scanner in "${available_scanners[@]}"; do
|
||||
echo " • ${scanner^}"
|
||||
done
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo -e "${CYAN}Create New Scan:${NC}"
|
||||
@@ -2590,6 +2603,13 @@ main() {
|
||||
# Don't exit if none found - menu option 9 allows installation
|
||||
detect_scanners || true
|
||||
|
||||
# Verify show_scan_menu exists and is callable
|
||||
if ! declare -f "show_scan_menu" &>/dev/null; then
|
||||
echo "ERROR: show_scan_menu function not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Call the menu function
|
||||
show_scan_menu
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user