Security Analysis for Cyber-Physical Systems