Commit Graph

10517 Commits

Author SHA1 Message Date
Ilija Lazoroski dcd9cab0f4 Project: Remove clear_simulation_data entry from vulture_allowlist 2022-09-13 13:40:54 +02:00
Ilija Lazoroski 62ab6e5a77 Common: Add generic events to PydanticEventSerializer 2022-09-13 13:38:41 +02:00
Ilija Lazoroski 88d65f40ae Project: Add PydanticEventSerializer to vulture_allowlist 2022-09-13 13:38:41 +02:00
Ilija Lazoroski 9e9160304c UT: Add unit tests for PydanticEventSerializer 2022-09-13 13:38:41 +02:00
Ilija Lazoroski 1755d72ae7 Common: Export PydanticEventSerializer from __init__ 2022-09-13 13:38:33 +02:00
Ilija Lazoroski e756e0dbc3 Common: Implement EventSerializer for pydantic objects 2022-09-13 13:38:26 +02:00
Mike Salvatore d58d8bb87b Island: Remove RepositoryService
Issue #2234
2022-09-13 07:26:13 -04:00
Mike Salvatore b226c84b6c
Merge pull request #2277 from guardicore/2234-refactor-clear-simulation-data
2234 refactor clear simulation data
2022-09-13 07:25:49 -04:00
Mike Salvatore 7c86bfc182 Island: Rename _handle_*_events() -> _subscribe_*_events() 2022-09-13 07:24:25 -04:00
Ilija Lazoroski f944347644 UT: Test ResetAgentConfiguration endpoint 2022-09-13 11:41:08 +02:00
Ilija Lazoroski f87fb39b0f Project: Add clear_simulation_data to vulture_allowlist
Remove once #2277 is closed
2022-09-13 11:30:13 +02:00
Mike Salvatore 4e49e59447 Island: Rename local event_queue -> island_event_queue
Disambiguate Island event queues from Agent event queues
2022-09-13 11:07:35 +02:00
Mike Salvatore 6d297dc201 Island: Subscribe legacy Database.reset_db to CLEAR_SIMULATION_DATA 2022-09-13 11:07:35 +02:00
Mike Salvatore 9479b56722 Island: Subscribe ICredentialsRepository to CLEAR_SIMULATION_DATA 2022-09-13 11:07:35 +02:00
Mike Salvatore 745027bf93 Island: Wrap island event handler setup in separate function 2022-09-13 11:07:35 +02:00
Mike Salvatore 7f29e0342d Island: Use interface instead of concrete in island_event_handlers 2022-09-13 11:07:35 +02:00
Mike Salvatore ba724db969 Island: Publish IslandEventTopic.CLEAR_SIMULATION_DATA from resource 2022-09-13 11:07:35 +02:00
Mike Salvatore 2c750acc7a Island: Return 204 No Content from ClearSimulationData POST 2022-09-13 11:07:35 +02:00
ilija-lazoroski e0fb651c69
Merge pull request #2276 from guardicore/2234-refactor-reset-agent-config
2234 refactor reset agent config
2022-09-13 10:55:47 +02:00
Ilija Lazoroski afa6c6b159 Island: Rename event_queue to island_event_queue 2022-09-13 10:44:52 +02:00
Ilija Lazoroski 2bfb85a652 UT: Add typehints to test_reset_agent_configuration 2022-09-13 09:33:48 +02:00
Ilija Lazoroski 599c753cf7 Island: Add docstrings to reset_agent_configuration event handler 2022-09-13 09:31:38 +02:00
Mike Salvatore 70978f9b30 Merge branch '2216-find-servers-concurrently' into 2216-fix-connection-issues 2022-09-12 16:49:07 -04:00
Kekoa Kaaikala 3dd2052dc5 Agent: Add debug logging to TCPRelay 2022-09-12 20:45:37 +00:00
Mike Salvatore c532cdec72 Agent: Detect closed socket in SocketsPipe
When a socket is closed, select.select() returns the socket in the
read_list. A closed socket can be detected by attempting to read from
it. If 0 data is read, then the socket is closed.

See below for more details:
> If a socket is in the output readable list, you can be
  as-close-to-certain-as-we-ever-get-in-this-business that a recv on
  that socket will return something.
https://docs.python.org/3/howto/sockets.html#non-blocking-sockets
https://stackoverflow.com/questions/17386487/python-detect-when-a-socket-disconnects-for-any-reason
https://stackoverflow.com/questions/17705239/is-there-a-way-to-detect-that-tcp-socket-has-been-closed-by-the-remote-peer-wit
2022-09-12 16:35:36 -04:00
Mike Salvatore fe954bb659 Agent: Call pipe.start(), not run()
run() blocks, start() starts the run method on a different thread.
2022-09-12 16:31:03 -04:00
Mike Salvatore 9002c47d56 Agent: Add a timeout on TCPPipeSpawner dest socket 2022-09-12 16:29:19 -04:00
Mike Salvatore 77c97062eb Agent: Wrap relay stop logic in a method 2022-09-12 14:53:19 -04:00
Mike Salvatore 27cb2009fc Agent: Let relay run indefinitely if user hasn't forced a stop 2022-09-12 14:46:42 -04:00
Mike Salvatore ea47fc326a Island: Remove extra newline from server_setup.py 2022-09-12 14:15:08 -04:00
Mike Salvatore 0e112cc31a Island: Wire up event handlers before starting the island server
_start_island_server() blocks, so event handlers need to be
wired/subscribed before the server starts.
2022-09-12 14:12:30 -04:00
Mike Salvatore ecab1be70e Island: Change IslandEventTopic definition from dynamic to static
My code completion tool doesn't play well with dynamically defined
Enums.
2022-09-12 13:35:47 -04:00
Mike Salvatore 8b49554cb5 Island: Add island_event_handlers package 2022-09-12 12:00:05 -04:00
Mike Salvatore 3e67f5696c Island: Move setup_island_event_handlers to monkey_island.cc.setup 2022-09-12 11:56:34 -04:00
Mike Salvatore c02f87add0 Merge branch '2234-extract-network-utils-from-services' into 2234-refactor-reset-agent-config 2022-09-12 11:53:19 -04:00
Mike Salvatore ad3dd6ba36 Island: Move network_utils from services/ -> server_utils/ 2022-09-12 11:52:53 -04:00
Mike Salvatore 285e6aaa35 Island: Remove disused local_ips() functions 2022-09-12 11:48:36 -04:00
Mike Salvatore 4bc9f735be Island: Rename setup_island_event_{subscribers,handlers} 2022-09-12 11:25:58 -04:00
Mike Salvatore fd7a00a225 Island: Rename subscribe_to_topics() -> setup_island_event_subscribers() 2022-09-12 11:20:17 -04:00
vakaris_zilius c2c2993ff7 Agent: Fix a bug(peeking socket consumes data)
sock.recv takes two parameters instead of one
2022-09-12 15:01:21 +00:00
Mike Salvatore a01785838d Agent: Pass keep_tunnel_open timeout as new_client_timeout 2022-09-12 10:24:26 -04:00
Mike Salvatore 67893b7825 Agent: Find/check island servers concurrently 2022-09-12 10:16:54 -04:00
Mike Salvatore a9edbb2874 Agent: Add ThreadSafeIterator 2022-09-12 10:16:51 -04:00
Ilija Lazoroski 0ca13eb93d Island: Add subscribe_to_topics on server setup 2022-09-12 15:59:58 +02:00
Ilija Lazoroski b834bfe7f7 Island: Publish RESET_AGENT_CONFIGURATION from endpoint 2022-09-12 15:22:09 +02:00
Mike Salvatore 191ee1a5f9 Agent: Change order of spawn pipe and add relay user
If we were unsuccessful in starting the pipe, we don't want to sit
around and wait for a relay user to connect.
2022-09-12 08:12:17 -04:00
vakarisz 7ff61423dc Agent: Log uncaught errors in tcp_connection_handler.py thread
If there's an uncaught error in the thread, the error won't propagate to the caller and we wouldn't know what went wrong from the logs. This fixes things and all uncaught errors get logged
2022-09-12 12:02:34 +00:00
Kekoa Kaaikala 9ff92d2128 Agent: Fix ident not available in constructor 2022-09-12 11:59:22 +00:00
Kekoa Kaaikala 756bfe488b Agent: Provide address as string to connect() 2022-09-12 11:59:22 +00:00
Ilija Lazoroski f9b1c5ebd2 Island: Export reset_agent_configuration from __init__ 2022-09-12 13:21:52 +02:00