Added logs to monkey island startup with hashes of executeables, for ease of deployment + debugging
Should ease the "wait which monkey am I running" issue a bit
This commit is contained in:
parent
cde256e4b9
commit
3a8a1f446b
|
@ -25,6 +25,7 @@ from monkey_island.cc.services.reporting.exporter_init import populate_exporter_
|
|||
from monkey_island.cc.utils import local_ip_addresses
|
||||
from monkey_island.cc.environment.environment import env
|
||||
from monkey_island.cc.database import is_db_server_up, get_db_version
|
||||
from monkey_island.cc.resources.monkey_download import MonkeyDownload
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -49,12 +50,19 @@ def main():
|
|||
ssl_options={'certfile': os.environ.get('SERVER_CRT', crt_path),
|
||||
'keyfile': os.environ.get('SERVER_KEY', key_path)})
|
||||
http_server.listen(env.get_island_port())
|
||||
logger.info(
|
||||
'Monkey Island Server is running on https://{}:{}'.format(local_ip_addresses()[0], env.get_island_port()))
|
||||
|
||||
log_init_info()
|
||||
IOLoop.instance().start()
|
||||
|
||||
|
||||
def log_init_info():
|
||||
logger.info(
|
||||
'Monkey Island Server is running. Listening on the following URLs: {}'.format(
|
||||
", ".join(["https://{}:{}".format(x, env.get_island_port()) for x in local_ip_addresses()])
|
||||
)
|
||||
)
|
||||
MonkeyDownload.log_executable_hashes()
|
||||
|
||||
|
||||
def wait_for_mongo_db_server(mongo_url):
|
||||
while not is_db_server_up(mongo_url):
|
||||
logger.info('Waiting for MongoDB server on {0}'.format(mongo_url))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
@ -83,9 +84,32 @@ class MonkeyDownload(flask_restful.Resource):
|
|||
|
||||
if result:
|
||||
# change resulting from new base path
|
||||
real_path = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", 'binaries', result['filename'])
|
||||
executable_filename = result['filename']
|
||||
real_path = MonkeyDownload.get_executable_full_path(executable_filename)
|
||||
if os.path.isfile(real_path):
|
||||
result['size'] = os.path.getsize(real_path)
|
||||
return result
|
||||
|
||||
return {}
|
||||
|
||||
@staticmethod
|
||||
def get_executable_full_path(executable_filename):
|
||||
real_path = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", 'binaries', executable_filename)
|
||||
return real_path
|
||||
|
||||
@staticmethod
|
||||
def log_executable_hashes():
|
||||
"""
|
||||
Logs all the hashes of the monkey executables for debugging ease (can check what Monkey version you have etc.).
|
||||
"""
|
||||
filenames = set([x['filename'] for x in MONKEY_DOWNLOADS])
|
||||
for filename in filenames:
|
||||
filepath = MonkeyDownload.get_executable_full_path(filename)
|
||||
if os.path.isfile(filepath):
|
||||
with open(filepath, 'rb') as monkey_exec_file:
|
||||
logger.debug("{} (SHA-512): {}".format(
|
||||
filepath,
|
||||
hashlib.sha512(monkey_exec_file.read()).hexdigest())
|
||||
)
|
||||
else:
|
||||
logger.debug("No monkey executable for {}.".format(filepath))
|
||||
|
|
Loading…
Reference in New Issue