crond-jaist / AutoPentest-DRL

AutoPentest-DRL: Automated Penetration Testing Using Deep Reinforcement Learning
BSD 3-Clause "New" or "Revised" License
336 stars 85 forks source link

AssertionError: The environment must specify an observation space #9

Closed VisaCai closed 2 years ago

VisaCai commented 2 years ago

hi everyone, Please help. Thank you!


The output is:


Process attack graph into attack matrix... Traceback (most recent call last): File "./dqn_learn.py", line 32, in env = gym.make('dqnenv-v0') File "/usr/local/lib/python3.7/dist-packages/gym/envs/registration.py", line 685, in make env = PassiveEnvChecker(env) File "/usr/local/lib/python3.7/dist-packages/gym/wrappers/env_checker.py", line 26, in init ), "The environment must specify an observation space. https://www.gymlibrary.ml/content/environment_creation/" AssertionError: The environment must specify an observation space. https://www.gymlibrary.ml/content/environment_creation/

crond-jaist commented 2 years ago

Hi, Sorry for the delay, but we have never seen the error you mention. I suspect there is some version incompatibility with the packages that you are using (in particular "gym"). Note that we did the development on Ubuntu 18.04 LTS, so if you are using a newer version problems like this can occur. Do let us know if you manage to find the cause of the problem. Best wishes, Razvan

VisaCai commented 2 years ago

Hi, Sorry for the delay, but we have never seen the error you mention. I suspect there is some version incompatibility with the packages that you are using (in particular "gym"). Note that we did the development on Ubuntu 18.04 LTS, so if you are using a newer version problems like this can occur. Do let us know if you manage to find the cause of the problem. Best wishes, Razvan

Yes, thank you for your support, the problem has been solved! I was using gym == 0.25.1 on Ubuntu 18.04 LTS before, now I turn the gym to version 0.23.1 and it worked.

monabasa commented 10 months ago

hello! Same question. And I install gym==0.23.1, but here comes new problem. ################################################################################ AutoPentest-DRL: Automated Penetration Testing Using Deep Reinforcement Learning ################################################################################ AutoPentest-DRL: Operation mode: Attack on logical network AutoPentest-DRL: Target topology: MulVAL_P/logical_topology_1.P

AutoPentest-DRL: Compute attack path for logical network... Generate attack graph using MulVAL... Process attack graph into attack matrix... Traceback (most recent call last): File "./confirm_path.py", line 9, in MAP = generateMapClass.sendMap File "./learn/generateMap.py", line 108, in sendMap self.x = self.createMatrix() File "./learn/generateMap.py", line 28, in createMatrix self.MAP = -(np.ones((self.line, self.line), dtype=np.float)) File "/usr/local/lib/python3.8/dist-packages/numpy/init.py", line 305, in getattr raise AttributeError(__former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'float'. np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations /usr/local/lib/python3.8/dist-packages/torch/init__.py:690: UserWarning: torch.set_default_tensor_type() is deprecated as of PyTorch 2.1, please use torch.set_default_dtype() and torch.set_default_device() as alternatives. (Triggered internally at ../torch/csrc/tensor/python_tensor.cpp:451.) _C._set_default_tensor_type(t) Conduct DQN training for up to 500 episodes...

AutoPentest-DRL: Optimal attack path was computed successfully (labels match 'mulval_result/AttackGraph.pdf') 26->24->17->16->15->13->10->9->8->6->5->4->3->2->1

Traceback (most recent call last): File "./dqn_learn.py", line 262, in env._close() File "/usr/local/lib/python3.8/dist-packages/gym/core.py", line 228, in getattr raise AttributeError(f"attempted to get missing private attribute '{name}'") AttributeError: attempted to get missing private attribute '_close'

Do you met the same question? How did you solve it?

monabasa commented 10 months ago

sorry to bother you, I've solved the question above. Thanks.

NhatVD1311 commented 8 months ago

@monabasa How did you solved? I also met same bugs.