Security and Insurance Management in Networks with Heterogeneous Agents