Threat Repair with Optimization Modulo Theories