Defending Against Diverse Attacks in Federated Learning Through Consensus-Based Bi-Level Optimization