예제 #1
0
 def setUp(self):
     self.config = get_config_for_testing()
     self.fw_one = create_test_firmware(device_name='dev_1', all_files_included_set=True)
     self.fw_one.processed_analysis['file_hashes'] = {'ssdeep': get_ssdeep(self.fw_one.binary)}
     self.fw_two = create_test_firmware(device_name='dev_2', bin_path='container/test.7z', all_files_included_set=True)
     self.fw_two.processed_analysis['file_hashes'] = {'ssdeep': get_ssdeep(self.fw_two.binary)}
     self.compare_system = Compare(db_interface=MockDbInterface(), config=self.config)
예제 #2
0
 def setUp(self):
     self._config = get_config_for_testing(TMP_DIR)
     self.mongo_server = MongoMgr(config=self._config)
     self.db_frontend_editing = FrontendEditingDbInterface(
         config=self._config)
     self.db_frontend_interface = FrontEndDbInterface(config=self._config)
     self.db_backend_interface = BackEndDbInterface(config=self._config)
예제 #3
0
def initialize_config(tmp_dir):
    config = get_config_for_testing(temp_dir=tmp_dir)

    # Database
    config.set('data_storage', 'main_database', 'tmp_integration_tests')
    config.set('data_storage', 'intercom_database_prefix',
               'tmp_integration_tests')
    config.set('data_storage', 'statistic_database', 'tmp_integration_tests')
    config.set('data_storage', 'view_storage', 'tmp_view_storage')

    # Analysis
    config.add_section('ip_and_uri_finder')
    config.set('ip_and_uri_finder', 'signature_directory',
               'analysis/signatures/ip_and_uri_finder/')
    config.add_section('default_plugins')
    config.set('default_plugins', 'plugins', 'file_hashes')

    # Unpacker
    config.set('unpack', 'threads', '2')
    config.set('ExpertSettings', 'unpack_throttle_limit', '20')

    # Compare
    config.set('ExpertSettings', 'ssdeep_ignore', '80')
    config.set('ExpertSettings', 'block_delay', '1')
    config.set('ExpertSettings', 'throw_exceptions', 'true')

    return config
예제 #4
0
    def setUp(self):
        self._config = get_config_for_testing(TMP_DIR)
        self._config.set('data_storage', 'report_threshold', '32')
        self._config.set('data_storage', 'sanitize_database', 'tmp_sanitize')
        self.mongo_server = MongoMgr(config=self._config)
        self.db_interface = MongoInterfaceCommon(config=self._config)
        self.db_interface_backend = BackEndDbInterface(config=self._config)

        self.test_firmware = create_test_firmware()

        self.test_yara_match = {
            'rule': 'OpenSSH',
            'tags': [],
            'namespace': 'default',
            'strings': [(0, '$a', b'OpenSSH')],
            'meta': {
                'description': 'SSH library',
                'website': 'http://www.openssh.com',
                'open_source': True,
                'software_name': 'OpenSSH'
            },
            'matches': True
        }

        self.test_fo = create_test_file_object()
예제 #5
0
def test_get_radare_endpoint():
    config = get_config_for_testing()

    assert config.get('ExpertSettings', 'nginx') == 'false'
    assert get_radare_endpoint(config) == 'http://localhost:8000'

    config.set('ExpertSettings', 'nginx', 'true')
    assert get_radare_endpoint(config) == 'https://localhost/radare'
예제 #6
0
    def setUp(self):
        self.config = get_config_for_testing(TMP_DIR)

        self.mongo_mgr = MongoMgr(self.config)

        self.frontend = WebFrontEnd(config=self.config)
        self.frontend.app.config['TESTING'] = True
        self.test_client = self.frontend.app.test_client()
예제 #7
0
 def setUp(self):
     routes.FrontEndDbInterface = DbInterfaceMock
     app = Flask(__name__)
     app.config.from_object(__name__)
     app.config['TESTING'] = True
     app.jinja_env.filters['replace_uid_with_hid'] = lambda x: x
     app.jinja_env.filters['nice_unix_time'] = lambda x: x
     config = get_config_for_testing()
     self.plugin_routes = routes.PluginRoutes(app, config)
     self.test_client = app.test_client()
 def setUp(self):
     config = get_config_for_testing(TMP_DIR)
     self.test_queue = Queue()
     self.interface = InterComBackEndBinding(
         config=config,
         testing=True,
         analysis_service=AnalysisServiceMock(),
         compare_service=ServiceMock(self.test_queue),
         unpacking_service=ServiceMock(self.test_queue))
     self.interface.WAIT_TIME = 2
     self.db = MongoMgr(config=config)
    def setUp(self):
        self.config = get_config_for_testing()

        self.enter_patch = unittest.mock.patch(
            target='web_interface.frontend_main.add_flask_security_to_app',
            new=add_security_get_mocked)
        self.enter_patch.start()

        self.frontend = frontend_main.WebFrontEnd(config=self.config)

        self.frontend.app.config['TESTING'] = True
        self.test_client = self.frontend.app.test_client()
    def setUp(self):
        self._config = get_config_for_testing()
        self.mongo_server = MongoMgr(config=self._config)
        self.db_interface = MongoInterfaceCommon(config=self._config)
        self.db_interface_backend = BackEndDbInterface(config=self._config)
        self.db_interface_compare = CompareDbInterface(config=self._config)
        self.db_interface_admin = AdminDbInterface(config=self._config)

        self.fw_one = create_test_firmware()
        self.fw_two = create_test_firmware()
        self.fw_two.set_binary(b'another firmware')
        self.compare_dict = self._create_compare_dict()
예제 #11
0
    def setUp(self):
        self.mocked_interface = DatabaseMock()

        self.enter_patch = unittest.mock.patch(target='helperFunctions.web_interface.ConnectTo.__enter__', new=lambda _: self.mocked_interface)
        self.enter_patch.start()

        self.exit_patch = unittest.mock.patch(target='helperFunctions.web_interface.ConnectTo.__exit__', new=fake_exit)
        self.exit_patch.start()

        self.config = get_config_for_testing(TMP_DIR)
        self.frontend = WebFrontEnd(config=self.config)
        self.frontend.app.config['TESTING'] = True
        self.test_client = self.frontend.app.test_client()
예제 #12
0
 def setUp(self):
     routes.FrontEndDbInterface = DbInterfaceMock
     app = Flask(__name__)
     app.config.from_object(__name__)
     app.config['TESTING'] = True
     config = get_config_for_testing()
     api = Api(app)
     endpoint, methods = routes.QemuExecRoutesRest.ENDPOINTS[0]
     api.add_resource(routes.QemuExecRoutesRest,
                      endpoint,
                      methods=methods,
                      resource_class_kwargs={'config': config})
     self.test_client = app.test_client()
예제 #13
0
    def setUp(self):
        self.mocked_interface = DatabaseMock()
        self.enter_patch = mock.patch(target='helperFunctions.web_interface.ConnectTo.__enter__', new=lambda _: self.mocked_interface)
        self.enter_patch.start()
        self.exit_patch = mock.patch(target='helperFunctions.web_interface.ConnectTo.__exit__', new=fake_exit)
        self.exit_patch.start()

        config = get_config_for_testing()
        config.add_section('ip_and_uri_finder')
        config.set('ip_and_uri_finder', 'signature_directory', 'analysis/signatures/ip_and_uri_finder/')
        config.set('default_plugins', 'default', 'file_hashes')
        self.tmp_queue = Queue()
        self.sched = AnalysisScheduler(config=config, pre_analysis=lambda *_: None, post_analysis=self.dummy_callback, db_interface=self.mocked_interface)
예제 #14
0
 def setUpClass(cls):
     cls.config = get_config_for_testing(TMP_DIR)
     cls.config.set('data_storage', 'sanitize_database', 'tmp_sanitize')
     cls.config.set('data_storage', 'report_threshold', '32')
     cls.mongo_server = MongoMgr(config=cls.config)
예제 #15
0
 def setup(self):
     self.sched.config = get_config_for_testing()
예제 #16
0
 def setUpClass(cls):
     cls._config = get_config_for_testing()
     cls.mongo_server = MongoMgr(config=cls._config)
예제 #17
0
 def setUpClass(cls):
     cls.config = get_config_for_testing(temp_dir=TMP_DIR)
     cls.config.set('ExpertSettings', 'communication_timeout', '1')
     cls.mongo_server = MongoMgr(config=cls.config)
예제 #18
0
import gc

from helperFunctions.config import get_config_for_testing
from storage.MongoMgr import MongoMgr
from storage.db_interface_view_sync import ViewUpdater, ViewReader

CONFIG = get_config_for_testing()
TEST_DATA = b'test data'


def test_view_sync_interface():
    mongo_server = MongoMgr(config=CONFIG)

    view_update_service = ViewUpdater(config=CONFIG)
    view_update_service.update_view('test', TEST_DATA)
    view_update_service.shutdown()

    view_read_service = ViewReader(config=CONFIG)
    assert view_read_service.get_view('none_existing') is None
    assert view_read_service.get_view('test') == TEST_DATA
    view_read_service.shutdown()

    mongo_server.shutdown()
    gc.collect()
 def setUp(self):
     config = get_config_for_testing(temp_dir=TMP_DIR)
     self.mongo_server = MongoMgr(config=config)
     self.generic_listener = InterComListener(config=config)
 def setUp(self):
     self._config = get_config_for_testing(TMP_DIR)
     self.mongo_server = MongoMgr(config=self._config)
     self.db_frontend_interface = FrontEndDbInterface(config=self._config)
     self.db_backend_interface = BackEndDbInterface(config=self._config)
     self.test_firmware = create_test_firmware()
예제 #21
0
 def setUpClass(cls):
     cls.tmp_dir = TemporaryDirectory(prefix='fact_test_')
     cls.config = get_config_for_testing(temp_dir=cls.tmp_dir)
     cls.config.set('ExpertSettings', 'communication_timeout', '1')
     cls.mongo_server = MongoMgr(config=cls.config)
예제 #22
0
 def setUp(self):
     self._config = get_config_for_testing(TMP_DIR)
     self.mongo_server = MongoMgr(config=self._config)
     self.db_interface = MongoInterfaceCommon(config=self._config)
     self.db_interface_backend = BackEndDbInterface(config=self._config)
예제 #23
0
 def setUp(self):
     self.app = Flask(__name__)
     self.app.config.from_object(__name__)
     self.api = Api(self.app)
     self.config = get_config_for_testing()
예제 #24
0
def test_config():
    return get_config_for_testing(TemporaryDirectory())
예제 #25
0
 def __init__(self):
     self.tag_queue = Queue()
     self.config = get_config_for_testing()
     self.db_backend_service = DatabaseMock(None)
예제 #26
0
 def setUp(self):
     self.config = get_config_for_testing()
     self.repack_service = tarRepack(config=self.config)
예제 #27
0
def config():
    return get_config_for_testing()
예제 #28
0
 def setUp(self):
     yara_binary_search.YaraBinarySearchScannerDbInterface.__bases__ = (
         MockCommonDbInterface, )
     self.db_interface = yara_binary_search.YaraBinarySearchScannerDbInterface(
         get_config_for_testing())
예제 #29
0
 def setUpClass(cls):
     cls.config = get_config_for_testing(TMP_DIR)
     cls.mongo_mgr = MongoMgr(cls.config)
예제 #30
0
 def setUp(self):
     self.config = get_config_for_testing()
     self.mongo_server = MongoMgr(config=self.config)
     self.workload_stat = WorkLoadStatistic(config=self.config,
                                            component='test')
     self.frontend_db_interface = StatisticDbViewer(config=self.config)