def test_minimum_steps(self): nS = 1 nM = 3 config = generate_config(nM, nS, self.r_sensitive, self.r_user, uniform=True) network = Network(config) actual = network.get_minimal_steps() expected = 3 self.assertEqual(actual, expected) nM = 8 config = generate_config(nM, nS, self.r_sensitive, self.r_user, uniform=True) network = Network(config) actual = network.get_minimal_steps() expected = 4 self.assertEqual(actual, expected) nM = 13 config = generate_config(nM, nS, self.r_sensitive, self.r_user, uniform=True) network = Network(config) actual = network.get_minimal_steps() expected = 4 self.assertEqual(actual, expected) nM = 18 config = generate_config(nM, nS, self.r_sensitive, self.r_user, uniform=True) network = Network(config) actual = network.get_minimal_steps() expected = 5 self.assertEqual(actual, expected) nM = 38 config = generate_config(nM, nS, self.r_sensitive, self.r_user, uniform=True) network = Network(config) actual = network.get_minimal_steps() expected = 6 self.assertEqual(actual, expected)
def setUp(self): self.r_sensitive = 1000 self.r_user = 1000 self.M = 3 self.S = 3 self.config = generate_config(self.M, self.S, self.r_sensitive, self.r_user) self.network = Network(self.config)
def test_generate_firewall_two_exploits_none_restricted(self): nM = 3 nS = 2 config = loader.generate_config(nM, nS, 1, 1, restrictiveness=5) firewall = config['firewall'] num_subnets = USER + 1 for src in range(num_subnets): for dest in range(num_subnets): services = firewall[src][dest] if (src != INTERNET and dest == INTERNET) or (src == INTERNET and dest > DMZ): for s in services: self.assertFalse(s) else: for s in services: self.assertTrue(s)
def get_network(self, nM, nS): config = generate_config(nM, nS, self.r_sensitive, self.r_user) network = Network(config) return network
def test_correllated_configs(self): nM = 40 nS = 10 alpha_H = [0.5, 1, 2.5, 5, 10] alpha_V = [0.5, 1, 2.5, 5, 10] lambda_V = [1, 2.5, 5, 10] # test generating network with uniform dist of configs print("Test Uniform dist of configurations") config = generate_config(nM, nS, self.r_sensitive, self.r_user, uniform=True) network = Network(config) num_configs, max_same = self.num_similiar_configs(network) print("\tUniform: num_configs={0}, max_same_configs={1}".format( num_configs, max_same)) max_vulns, avg_vulns = self.num_exploits_avail(nS, nM, network) print("\tUniform: max_vulns={0}, avg_vulns={1}".format( max_vulns, avg_vulns)) # for each compare number of similar configs for range of alpha_H print("Test alpha_H") for h in alpha_H: config = generate_config(nM, nS, self.r_sensitive, self.r_user, alpha_H=h) network = Network(config) num_configs, max_same = self.num_similiar_configs(network) print( "\talpha_H={0}, num_configs={1}, max_same_configs={2}".format( h, num_configs, max_same)) # for each compare number of similar configs and services for range of alpha_V print("Test alpha_V") for v in alpha_V: config = generate_config(nM, nS, self.r_sensitive, self.r_user, alpha_V=v) network = Network(config) num_configs, max_same = self.num_similiar_configs(network) print( "\talpha_V={0}, num_configs={1}, max_same_configs={2}".format( v, num_configs, max_same)) # for each compare number of services per machine for range of lambda_V print("Test lambda_V") for l in lambda_V: config = generate_config(nM, nS, self.r_sensitive, self.r_user, lambda_V=l) network = Network(config) max_vulns, avg_vulns = self.num_exploits_avail(nS, nM, network) print("\tlambda_V={0}, max_vulns={1}, avg_vulns={2}".format( l, max_vulns, avg_vulns))