Skip to content

Commit 07b3732

Browse files
committed
minor changes to:
1) ht_on in __init__.py 2) logging of exploration\exploitation
1 parent a218dae commit 07b3732

File tree

9 files changed

+1705600
-2913
lines changed

9 files changed

+1705600
-2913
lines changed

cyberbattle/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ def register(id: str, cyberbattle_env_identifiers: model.Identifiers, **kwargs):
124124
# )
125125

126126

127-
max_ht_on = len(ht_on)
127+
max_ht_on = len(configuration.honeytokens_on)
128128
for i in range(1, max_ht_on + 1):
129129
for j in range(i + 1, max_ht_on + 1):
130130

131131
ver = str(i) + str(j)
132132
if 'CyberBattleTinyMicro-v' + ver in registry.env_specs:
133133
del registry.env_specs['CyberBattleTinyMicro-v' + ver]
134134

135-
ht_on = dict(zip(list(ht_on.keys()),
135+
ht_on = dict(zip(list(sorted(configuration.honeytokens_on.keys())),
136136
[True if k in [i, j] else False for k in range(1, max_ht_on + 1)]))
137137
tinymicro_deception_constructor.reconfigure_environment(ht_on)
138138

@@ -150,14 +150,13 @@ def register(id: str, cyberbattle_env_identifiers: model.Identifiers, **kwargs):
150150
max_episode_steps=50,
151151
)
152152

153-
max_ht_on = len(ht_on)
154153
for i in range(1, max_ht_on + 1):
155154

156155
ver = ''.join([str(k) for k in range(1, max_ht_on + 1) if k != i])
157156
if 'CyberBattleTinyMicro-v' + ver in registry.env_specs:
158157
del registry.env_specs['CyberBattleTinyMicro-v' + ver]
159158

160-
ht_on = dict(zip(list(ht_on.keys()),
159+
ht_on = dict(zip(list(sorted(configuration.honeytokens_on.keys())),
161160
[True if k != i else False for k in range(1, max_ht_on + 1)]))
162161
tinymicro_deception_constructor.reconfigure_environment(ht_on)
163162

cyberbattle/agents/baseline/agent_dql.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ def explore(self, wrapped_env: w.AgentWrapper
415415
) -> Tuple[str, cyberbattle_env.Action, object]:
416416
"""Random exploration that avoids repeating actions previously taken in the same state"""
417417
# sample local and remote actions only (excludes connect action)
418-
logger.info("Enter exploration phase instead of exploitation.")
419418
gym_action = wrapped_env.env.sample_valid_action(kinds=[0, 1, 2])
420419
metadata = self.metadata_from_gymaction(wrapped_env, gym_action)
421420
return "explore", gym_action, metadata

cyberbattle/agents/baseline/agent_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def specialize_to_gymaction(self, source_node: np.int32, observation, abstract_a
386386
if discovered_nodes_count <= 1:
387387
return None
388388

389-
# # NOTE: We can do better here than random pick: ultimately this
389+
# # NOTE: BEFORE We can do better here than random pick: ultimately this
390390
# # should be learnt from target node properties
391391
# # NOTE: NOW we have each vulnerability unique based on node where it was writter
392392
# # choosing remote vulnerability among identifiers.remote_vulnerabilities,

cyberbattle/agents/baseline/learner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,11 @@ def epsilon_greedy_search(
561561
x = np.random.rand()
562562
if x <= epsilon:
563563
action_style, gym_action, action_metadata = learner.explore(wrapped_env)
564+
logger.info("Choose exploration phase")
564565
else:
565566
action_style, gym_action, action_metadata = learner.exploit(wrapped_env, observation)
566567
if not gym_action:
568+
logger.info("Enter exploration phase instead of exploitation")
567569
stats['exploit_deflected_to_explore'] += 1
568570
_, gym_action, action_metadata = learner.explore(wrapped_env)
569571

cyberbattle/agents/baseline/notebooks/notebook_dql_debug_with_tinymicro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
log_results = os.getenv("LOG_RESULTS", 'False').lower() in ('true', '1', 't')
5151
gymid = os.getenv("GYMID", 'CyberBattleTinyMicro-v0')
5252
log_level = os.getenv('LOG_LEVEL', "info")
53-
seed = int(os.getenv('SEED', 0))
53+
seed = float(os.getenv('SEED', 0))
5454
iteration_count = None
5555
honeytokens_on = None
5656
training_episode_count = None

0 commit comments

Comments
 (0)