forked from p34709852/monkey
Added boilerplate methods for mongodb launch.
This commit is contained in:
parent
2621458b37
commit
66b3fb1d47
|
@ -24,13 +24,13 @@ from common.version import get_version # noqa: E402
|
||||||
from monkey_island.cc.app import init_app # noqa: E402
|
from monkey_island.cc.app import init_app # noqa: E402
|
||||||
from monkey_island.cc.database import get_db_version # noqa: E402
|
from monkey_island.cc.database import get_db_version # noqa: E402
|
||||||
from monkey_island.cc.database import is_db_server_up # noqa: E402
|
from monkey_island.cc.database import is_db_server_up # noqa: E402
|
||||||
|
from monkey_island.cc.mongo_setup import init_collections, launch_mongodb # noqa: E402
|
||||||
from monkey_island.cc.resources.monkey_download import MonkeyDownload # noqa: E402
|
from monkey_island.cc.resources.monkey_download import MonkeyDownload # noqa: E402
|
||||||
from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402
|
from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402
|
||||||
from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402
|
from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402
|
||||||
from monkey_island.cc.services.initialize import initialize_services # noqa: E402
|
from monkey_island.cc.services.initialize import initialize_services # noqa: E402
|
||||||
from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402
|
from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402
|
||||||
from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402
|
from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402
|
||||||
from monkey_island.cc.setup import setup # noqa: E402
|
|
||||||
|
|
||||||
MINIMUM_MONGO_DB_VERSION_REQUIRED = "4.2.0"
|
MINIMUM_MONGO_DB_VERSION_REQUIRED = "4.2.0"
|
||||||
|
|
||||||
|
@ -47,11 +47,13 @@ def main(setup_only: bool, server_config_path: str, config_options: IslandConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
bootloader_server_thread.start()
|
bootloader_server_thread.start()
|
||||||
start_island_server(setup_only)
|
start_island_server(setup_only, config_options)
|
||||||
bootloader_server_thread.join()
|
bootloader_server_thread.join()
|
||||||
|
|
||||||
|
|
||||||
def start_island_server(should_setup_only):
|
def start_island_server(should_setup_only, config_options: IslandConfigOptions):
|
||||||
|
if config_options.start_mongodb:
|
||||||
|
launch_mongodb()
|
||||||
mongo_url = os.environ.get("MONGO_URL", env_singleton.env.get_mongo_url())
|
mongo_url = os.environ.get("MONGO_URL", env_singleton.env.get_mongo_url())
|
||||||
wait_for_mongo_db_server(mongo_url)
|
wait_for_mongo_db_server(mongo_url)
|
||||||
assert_mongo_db_version(mongo_url)
|
assert_mongo_db_version(mongo_url)
|
||||||
|
@ -62,7 +64,7 @@ def start_island_server(should_setup_only):
|
||||||
crt_path = str(Path(MONKEY_ISLAND_ABS_PATH, "cc", "server.crt"))
|
crt_path = str(Path(MONKEY_ISLAND_ABS_PATH, "cc", "server.crt"))
|
||||||
key_path = str(Path(MONKEY_ISLAND_ABS_PATH, "cc", "server.key"))
|
key_path = str(Path(MONKEY_ISLAND_ABS_PATH, "cc", "server.key"))
|
||||||
|
|
||||||
setup()
|
init_collections()
|
||||||
|
|
||||||
if should_setup_only:
|
if should_setup_only:
|
||||||
logger.warning("Setup only flag passed. Exiting.")
|
logger.warning("Setup only flag passed. Exiting.")
|
||||||
|
|
|
@ -9,7 +9,12 @@ from monkey_island.cc.services.attack.mitre_api_interface import MitreApiInterfa
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def launch_mongodb():
|
||||||
|
# TODO: Implement the launch of mongodb process
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def init_collections():
|
||||||
logger.info("Setting up the Monkey Island, this might take a while...")
|
logger.info("Setting up the Monkey Island, this might take a while...")
|
||||||
try_store_mitigations_on_mongo()
|
try_store_mitigations_on_mongo()
|
||||||
|
|
Loading…
Reference in New Issue