Merged PR 308: Fix stubborn logs and default config values
## Summary Ensure that the logging options are being read correctly from the config. Makes logs actually optional. Also temporarily disable checkhash and replace it with file scan because checkhash is buggy. ## Test process By inspection ## Checklist - [x] PR is linked to a **work item** - [x] **acceptance criteria** of linked ticket are met - [x] performed **self-review** of the code - [ ] written **tests** for any new functionality added with this PR - [ ] updated the **documentation** if this PR changes or adds functionality - [ ] written/updated **design docs** if this PR implements new functionality - [ ] updated the **change log** - [x] ran **pre-commit** checks for code style - [x] attended to any **TO-DOs** left in the code Fix some stuff Related work items: #2382
This commit is contained in:
@@ -11,16 +11,14 @@ training_config:
|
|||||||
- defender
|
- defender
|
||||||
|
|
||||||
io_settings:
|
io_settings:
|
||||||
save_checkpoints: true
|
|
||||||
checkpoint_interval: 5
|
|
||||||
save_agent_actions: true
|
save_agent_actions: true
|
||||||
save_step_metadata: false
|
save_step_metadata: false
|
||||||
save_pcap_logs: false
|
save_pcap_logs: false
|
||||||
save_sys_logs: true
|
save_sys_logs: false
|
||||||
|
|
||||||
|
|
||||||
game:
|
game:
|
||||||
max_episode_length: 256
|
max_episode_length: 128
|
||||||
ports:
|
ports:
|
||||||
- HTTP
|
- HTTP
|
||||||
- POSTGRES_SERVER
|
- POSTGRES_SERVER
|
||||||
@@ -323,7 +321,7 @@ agents:
|
|||||||
folder_id: 0
|
folder_id: 0
|
||||||
file_id: 0
|
file_id: 0
|
||||||
10:
|
10:
|
||||||
action: "NODE_FILE_CHECKHASH"
|
action: "NODE_FILE_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context.
|
||||||
options:
|
options:
|
||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
@@ -351,7 +349,7 @@ agents:
|
|||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
15:
|
15:
|
||||||
action: "NODE_FOLDER_CHECKHASH"
|
action: "NODE_FOLDER_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context.
|
||||||
options:
|
options:
|
||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ training_config:
|
|||||||
seed: 333
|
seed: 333
|
||||||
n_learn_episodes: 1
|
n_learn_episodes: 1
|
||||||
n_eval_episodes: 5
|
n_eval_episodes: 5
|
||||||
max_steps_per_episode: 256
|
max_steps_per_episode: 128
|
||||||
deterministic_eval: false
|
deterministic_eval: false
|
||||||
n_agents: 2
|
n_agents: 2
|
||||||
agent_references:
|
agent_references:
|
||||||
@@ -22,7 +22,7 @@ io_settings:
|
|||||||
|
|
||||||
|
|
||||||
game:
|
game:
|
||||||
max_episode_length: 256
|
max_episode_length: 128
|
||||||
ports:
|
ports:
|
||||||
- ARP
|
- ARP
|
||||||
- DNS
|
- DNS
|
||||||
@@ -325,7 +325,7 @@ agents:
|
|||||||
folder_id: 0
|
folder_id: 0
|
||||||
file_id: 0
|
file_id: 0
|
||||||
10:
|
10:
|
||||||
action: "NODE_FILE_CHECKHASH"
|
action: "NODE_FILE_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context.
|
||||||
options:
|
options:
|
||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
@@ -353,7 +353,7 @@ agents:
|
|||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
15:
|
15:
|
||||||
action: "NODE_FOLDER_CHECKHASH"
|
action: "NODE_FOLDER_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context.
|
||||||
options:
|
options:
|
||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
@@ -876,7 +876,7 @@ agents:
|
|||||||
folder_id: 0
|
folder_id: 0
|
||||||
file_id: 0
|
file_id: 0
|
||||||
10:
|
10:
|
||||||
action: "NODE_FILE_CHECKHASH"
|
action: "NODE_FILE_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context.
|
||||||
options:
|
options:
|
||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
@@ -904,7 +904,7 @@ agents:
|
|||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
15:
|
15:
|
||||||
action: "NODE_FOLDER_CHECKHASH"
|
action: "NODE_FOLDER_SCAN" # CHECKHASH replaced by SCAN - but the behaviour is the same in this context.
|
||||||
options:
|
options:
|
||||||
node_id: 2
|
node_id: 2
|
||||||
folder_id: 0
|
folder_id: 0
|
||||||
|
|||||||
@@ -92,5 +92,5 @@ class PrimaiteIO:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_config(cls, config: Dict) -> "PrimaiteIO":
|
def from_config(cls, config: Dict) -> "PrimaiteIO":
|
||||||
"""Create an instance of PrimaiteIO based on a configuration dict."""
|
"""Create an instance of PrimaiteIO based on a configuration dict."""
|
||||||
new = cls()
|
new = cls(settings=cls.Settings(**config))
|
||||||
return new
|
return new
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class NetworkInterface(SimComponent, ABC):
|
|||||||
"""Reset the original state of the SimComponent."""
|
"""Reset the original state of the SimComponent."""
|
||||||
super().setup_for_episode(episode=episode)
|
super().setup_for_episode(episode=episode)
|
||||||
self.nmne = {}
|
self.nmne = {}
|
||||||
if episode and self.pcap:
|
if episode and self.pcap and SIM_OUTPUT.save_pcap_logs:
|
||||||
self.pcap.current_episode = episode
|
self.pcap.current_episode = episode
|
||||||
self.pcap.setup_logger()
|
self.pcap.setup_logger()
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class PacketCapture:
|
|||||||
|
|
||||||
self.current_episode: int = 1
|
self.current_episode: int = 1
|
||||||
|
|
||||||
|
if SIM_OUTPUT.save_pcap_logs:
|
||||||
self.setup_logger(outbound=False)
|
self.setup_logger(outbound=False)
|
||||||
self.setup_logger(outbound=True)
|
self.setup_logger(outbound=True)
|
||||||
|
|
||||||
@@ -108,6 +109,7 @@ class PacketCapture:
|
|||||||
|
|
||||||
:param frame: The PCAP frame to capture.
|
:param frame: The PCAP frame to capture.
|
||||||
"""
|
"""
|
||||||
|
if SIM_OUTPUT.save_pcap_logs:
|
||||||
msg = frame.model_dump_json()
|
msg = frame.model_dump_json()
|
||||||
self.inbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL
|
self.inbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL
|
||||||
|
|
||||||
@@ -117,5 +119,6 @@ class PacketCapture:
|
|||||||
|
|
||||||
:param frame: The PCAP frame to capture.
|
:param frame: The PCAP frame to capture.
|
||||||
"""
|
"""
|
||||||
|
if SIM_OUTPUT.save_pcap_logs:
|
||||||
msg = frame.model_dump_json()
|
msg = frame.model_dump_json()
|
||||||
self.outbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL
|
self.outbound_logger.log(level=60, msg=msg) # Log at custom log level > CRITICAL
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ training_config:
|
|||||||
- defender
|
- defender
|
||||||
|
|
||||||
io_settings:
|
io_settings:
|
||||||
save_checkpoints: true
|
save_agent_actions: false
|
||||||
checkpoint_interval: 5
|
|
||||||
save_agent_actions: true
|
|
||||||
save_step_metadata: false
|
save_step_metadata: false
|
||||||
save_pcap_logs: false
|
save_pcap_logs: false
|
||||||
save_sys_logs: true
|
save_sys_logs: false
|
||||||
|
|
||||||
|
|
||||||
game:
|
game:
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ training_config:
|
|||||||
- defender
|
- defender
|
||||||
|
|
||||||
io_settings:
|
io_settings:
|
||||||
save_checkpoints: true
|
save_agent_actions: true
|
||||||
checkpoint_interval: 5
|
save_step_metadata: true
|
||||||
|
save_pcap_logs: true
|
||||||
|
save_sys_logs: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
game:
|
game:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class TestPrimaiteSession:
|
|||||||
assert session.env.game.simulation.network
|
assert session.env.game.simulation.network
|
||||||
assert len(session.env.game.simulation.network.nodes) == 10
|
assert len(session.env.game.simulation.network.nodes) == 10
|
||||||
|
|
||||||
|
@pytest.mark.skip(reason="Session is not being maintained and will be removed in the subsequent beta release.")
|
||||||
@pytest.mark.parametrize("temp_primaite_session", [[CFG_PATH]], indirect=True)
|
@pytest.mark.parametrize("temp_primaite_session", [[CFG_PATH]], indirect=True)
|
||||||
def test_start_session(self, temp_primaite_session):
|
def test_start_session(self, temp_primaite_session):
|
||||||
"""Make sure you can go all the way through the session without errors."""
|
"""Make sure you can go all the way through the session without errors."""
|
||||||
|
|||||||
Reference in New Issue
Block a user