diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index 19c392e..0241007 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -1644,8 +1644,15 @@ delete_standalone_sessions() { ;; *) # Delete specific session + # Validate numeric input + if ! [[ "$delete_choice" =~ ^[0-9]+$ ]]; then + echo -e "${RED}Invalid choice (must be a number)${NC}" + read -p "Press Enter to continue..." + return 1 + fi + if [ "$delete_choice" -lt 1 ] || [ "$delete_choice" -gt ${#standalone_dirs[@]} ]; then - echo -e "${RED}Invalid choice${NC}" + echo -e "${RED}Invalid choice (out of range)${NC}" read -p "Press Enter to continue..." return 1 fi @@ -1766,8 +1773,15 @@ view_scan_results() { read -p "Scanner: " scanner_choice + # Validate numeric input + if ! [[ "$scanner_choice" =~ ^[0-9]+$ ]]; then + echo -e "${RED}Invalid choice (must be a number)${NC}" + read -p "Press Enter to continue..." + return 1 + fi + if [ "$scanner_choice" -lt 1 ] || [ "$scanner_choice" -gt ${#available_scanners[@]} ]; then - echo -e "${RED}Invalid choice${NC}" + echo -e "${RED}Invalid choice (out of range)${NC}" read -p "Press Enter to continue..." return 1 fi @@ -1827,12 +1841,19 @@ view_scan_results() { read -p "Select session (or 0 to cancel): " session_choice + # Validate numeric input + if ! [[ "$session_choice" =~ ^[0-9]+$ ]]; then + echo -e "${RED}Invalid choice (must be a number)${NC}" + read -p "Press Enter to continue..." + return 1 + fi + if [ "$session_choice" = "0" ]; then return 0 fi if [ "$session_choice" -lt 1 ] || [ "$session_choice" -gt ${#standalone_dirs[@]} ]; then - echo -e "${RED}Invalid choice${NC}" + echo -e "${RED}Invalid choice (out of range)${NC}" read -p "Press Enter to continue..." return 1 fi