Example #1
0
    def from_file(cls, path, scan_cost=SCAN_COST, seed=1):
        """
        Construct a new Cyber Attack Simulator Environment from a config file.

        Arguments:
            str path : path to the config file
            float scan_cost : cost of performing a scan action
            int seed : seed for environment

        Returns:
            CyberAttackSimulatorEnv env : a new environment object
        """
        config = loader.load_config(path)
        return cls(config, scan_cost, seed)
 def test_load_config_invalid_sensitive_machines(self):
     file = "inputs/invalid_config_sensitive_machines.yaml"
     with self.assertRaises(ValueError):
         loader.load_config(file)
 def test_load_config_invalid_services(self):
     file = "inputs/invalid_config_services.yaml"
     with self.assertRaises(TypeError):
         loader.load_config(file)
 def test_load_config_invalid_topology(self):
     file = "inputs/invalid_config_topology.yaml"
     with self.assertRaises(ValueError):
         loader.load_config(file)
 def test_load_config_invalid_subnets(self):
     file = "inputs/invalid_config_subnets.yaml"
     with self.assertRaises(ValueError):
         loader.load_config(file)
 def test_load_config_from_file_valid_config(self):
     expected = self.get_valid_config_dict()
     actual = loader.load_config("inputs/valid_config.yaml")
     self.assertDictEqual(expected, actual)