Chemical Reactions in Imperfect Cavities: Enhancement, Suppression, and Resonance