HostVector¶
This module contains the HostVector class.
This is the main class for storing and updating the state of a single host in the NASim environment.
-
class
nasim.envs.host_vector.
HostVector
(vector)¶ A Vector representation of a single host in NASim.
Each host is represented as a vector (1D numpy array) for efficiency and to make it easier to use with deep learning agents. The vector is made up of multiple features arranged in a consistent way.
Features in the vector, listed in order, are:
- subnet address - one-hot encoding with length equal to the number
- of subnets
- host address - one-hot encoding with length equal to the maximum number
- of hosts in any subnet
- compromised - bool
- reachable - bool
- discovered - bool
- value - float
- discovery value - float
- access - int
- OS - bool for each OS in scenario (only one OS has value of true)
- services running - bool for each service in scenario
- processes running - bool for each process in scenario
Notes
The size of the vector is equal to:
#subnets + max #hosts in any subnet + 6 + #OS + #services + #processes.
Where the +6 is for compromised, reachable, discovered, value, discovery_value, and access features
The vector is a float vector so True/False is actually represented as 1.0/0.0.
-
__init__
(vector)¶ Initialize self. See help(type(self)) for accurate signature.
-
perform_action
(action)¶ Perform given action against this host
Parameters: action (Action) – the action to perform Returns: - HostVector – the resulting state of host after action
- ActionObservation – the result from the action
-
classmethod
reset
()¶ Resets any class variables.
This is used to avoid errors when changing scenarios within a single python session