Merge pull request #622 from guardicore/bugfix/fix-win-installation

Bugfix/fix win installation
This commit is contained in:
Shay Nehmad 2020-04-20 15:23:46 +03:00 committed by GitHub
commit ab4977f191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 13 deletions

View File

@ -31,7 +31,7 @@ from monkey_island.cc.bootloader_server import BootloaderHttpServer
from monkey_island.cc.setup import setup from monkey_island.cc.setup import setup
def main(should_setup_only): def main(should_setup_only=False):
logger.info("Starting bootloader server") logger.info("Starting bootloader server")
mongo_url = os.environ.get('MONGO_URL', env.get_mongo_url()) mongo_url = os.environ.get('MONGO_URL', env.get_mongo_url())
bootloader_server_thread = Thread(target=BootloaderHttpServer(mongo_url).serve_forever, daemon=True) bootloader_server_thread = Thread(target=BootloaderHttpServer(mongo_url).serve_forever, daemon=True)

View File

@ -1,6 +1,6 @@
from typing import List, Dict from typing import List, Dict
from stix2 import FileSystemSource, Filter, CourseOfAction, AttackPattern, v20 from stix2 import FileSystemSource, Filter, CourseOfAction, AttackPattern
class MitreApiInterface: class MitreApiInterface:
@ -32,14 +32,14 @@ class MitreApiInterface:
return all_techniques return all_techniques
@staticmethod @staticmethod
def get_stix2_external_reference_id(stix2_data: v20._DomainObject) -> str: def get_stix2_external_reference_id(stix2_data) -> str:
for reference in stix2_data['external_references']: for reference in stix2_data['external_references']:
if reference['source_name'] == "mitre-attack" and 'external_id' in reference: if reference['source_name'] == "mitre-attack" and 'external_id' in reference:
return reference['external_id'] return reference['external_id']
return '' return ''
@staticmethod @staticmethod
def get_stix2_external_reference_url(stix2_data: v20._DomainObject) -> str: def get_stix2_external_reference_url(stix2_data) -> str:
for reference in stix2_data['external_references']: for reference in stix2_data['external_references']:
if 'url' in reference: if 'url' in reference:
return reference['url'] return reference['url']

View File

@ -5,7 +5,7 @@ from monkey_island.cc.database import mongo
from common.utils.attack_utils import ScanStatus from common.utils.attack_utils import ScanStatus
from monkey_island.cc.services.attack.attack_config import AttackConfig from monkey_island.cc.services.attack.attack_config import AttackConfig
from common.utils.code_utils import abstractstatic from common.utils.code_utils import abstractstatic
from cc.models.attack.attack_mitigations import AttackMitigations from monkey_island.cc.models.attack.attack_mitigations import AttackMitigations
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
import os import os
import platform import platform
import sys
__author__ = 'itay.mizeretz' __author__ = 'itay.mizeretz'
@ -9,15 +9,20 @@ block_cipher = None
def main(): def main():
# These data files and folders will be included in the bundle.
# The format of the tuples is (src, dest_dir). See https://pythonhosted.org/PyInstaller/spec-files.html#adding-data-files
added_datas = [
("../common/BUILD", "/common"),
("../monkey_island/cc/services/attack/attack_data", "/monkey_island/cc/services/attack/attack_data")
]
a = Analysis(['cc/main.py'], a = Analysis(['cc/main.py'],
pathex=['..'], pathex=['..'],
hiddenimports=get_hidden_imports(), hiddenimports=get_hidden_imports(),
hookspath=None, hookspath=[os.path.join(".", "pyinstaller_hooks")],
runtime_hooks=None, runtime_hooks=None,
binaries=None, binaries=None,
datas=[ datas=added_datas,
("../common/BUILD", "/common")
],
excludes=None, excludes=None,
win_no_prefer_redirects=None, win_no_prefer_redirects=None,
win_private_assemblies=None, win_private_assemblies=None,
@ -36,8 +41,7 @@ def main():
name=get_monkey_filename(), name=get_monkey_filename(),
debug=False, debug=False,
strip=get_exe_strip(), strip=get_exe_strip(),
upx=True, upx=False,
upx_exclude=['vcruntime140.dll'],
console=True, console=True,
icon=get_exe_icon()) icon=get_exe_icon())
@ -74,7 +78,7 @@ def get_linux_only_binaries():
def get_hidden_imports(): def get_hidden_imports():
return ['_cffi_backend', 'queue'] if is_windows() else ['_cffi_backend'] return ['_cffi_backend', 'queue', 'pkg_resources.py2_warn'] if is_windows() else ['_cffi_backend']
def get_msvcr(): def get_msvcr():

View File

@ -0,0 +1,7 @@
# Workaround for packaging Monkey Island using PyInstaller. See https://github.com/oasis-open/cti-python-stix2/issues/218
import os
from PyInstaller.utils.hooks import get_module_file_attribute
stix2_dir = os.path.dirname(get_module_file_attribute('stix2'))
datas = [(stix2_dir, 'stix2')]