Automating Device Security at IoT Scale