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)
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()
def binary_service(): with TemporaryDirectory(prefix='fact_test_') as tmp_dir: config = get_config_for_testing(temp_dir=tmp_dir) mongo_server = MongoMgr(config=config) _init_test_data(config, tmp_dir) yield BinaryService(config=config) mongo_server.shutdown() gc.collect()
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(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()
def main(command_line_options=sys.argv): _, config = program_setup(PROGRAM_NAME, PROGRAM_DESCRIPTION, command_line_options=command_line_options) logging.info('Trying to start Mongo Server and initializing users...') mongo_manger = MongoMgr(config=config, auth=False) mongo_manger.init_users() mongo_manger.shutdown() return 0
def setUp(self): self._tmp_dir = TemporaryDirectory() self._config = initialize_config(self._tmp_dir) self._mongo_server = MongoMgr(config=self._config, auth=False) self._analysis_scheduler = AnalysisScheduler(config=self._config) self._unpack_scheduler = UnpackingScheduler( config=self._config, post_unpack=self._analysis_scheduler.add_task) self._compare_scheduler = CompareScheduler(config=self._config)
def setUp(self): self._tmp_dir = TemporaryDirectory() self._config = initialize_config(self._tmp_dir) self.analysis_finished_event = Event() self.uid_of_key_file = '530bf2f1203b789bfe054d3118ebd29a04013c587efd22235b3b9677cee21c0e_2048' self._mongo_server = MongoMgr(config=self._config, auth=False) self.backend_interface = BackEndDbInterface(config=self._config) self._analysis_scheduler = AnalysisScheduler(config=self._config, pre_analysis=self.backend_interface.add_object, post_analysis=self.count_analysis_finished_event) self._unpack_scheduler = UnpackingScheduler(config=self._config, post_unpack=self._analysis_scheduler.start_analysis_of_object)
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()
def setUp(self): self._tmp_dir = TemporaryDirectory() self._config = initialize_config(self._tmp_dir) self.elements_finished_analyzing = Value('i', 0) self.analysis_finished_event = Event() self.compare_finished_event = Event() self._mongo_server = MongoMgr(config=self._config, auth=False) self.backend_interface = BackEndDbInterface(config=self._config) self._analysis_scheduler = AnalysisScheduler(config=self._config, post_analysis=self.count_analysis_finished_event) self._unpack_scheduler = UnpackingScheduler(config=self._config, post_unpack=self._analysis_scheduler.add_task) self._compare_scheduler = CompareScheduler(config=self._config, callback=self.trigger_compare_finished_event)
def setUp(self): self._set_config() self.mongo_server = MongoMgr(config=self.config) self.frontend = WebFrontEnd(config=self.config) self.frontend.app.config['TESTING'] = True self.test_client = self.frontend.app.test_client() self.test_fw_a = self.TestFW( '418a54d78550e8584291c96e5d6168133621f352bfc1d43cf84e81187fef4962_787', 'container/test.zip', 'test_fw_a') self.test_fw_b = self.TestFW( 'd38970f8c5153d1041810d0908292bc8df21e7fd88aab211a8fb96c54afe6b01_319', 'container/test.7z', 'test_fw_b')
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 main(command_line_options=sys.argv): _, config = program_setup(PROGRAM_NAME, PROGRAM_DESCRIPTION, command_line_options=command_line_options) logging.info('Trying to start Mongo Server and initializing users...') mongo_manger = MongoMgr(config=config, auth=False) db_service_frontend_editing = FrontendEditingDbInterface(config) convert_comments_to_new_format(db_service_frontend_editing) convert_release_dates_to_date_object_format(db_service_frontend_editing) add_parent_firmware_list_to_file_object(db_service_frontend_editing) mongo_manger.shutdown() return 0
def get_intercom_for_testing(): with TemporaryDirectory(prefix='fact_test_') as tmp_dir: config = get_config_for_testing(tmp_dir) test_queue = Queue() interface = InterComBackEndBinding( config=config, testing=True, analysis_service=AnalysisServiceMock(), compare_service=ServiceMock(test_queue), unpacking_service=ServiceMock(test_queue)) interface.WAIT_TIME = 2 db = MongoMgr(config=config) yield interface interface.shutdown() test_queue.close() db.shutdown() gc.collect()
def main(command_line_options=sys.argv): args, config = program_setup(PROGRAM_NAME, PROGRAM_DESCRIPTION, command_line_options=command_line_options) logging.info('Try to start Mongo Server...') mongo_server = MongoMgr(config=config) updater = StatisticUpdater(config=config) updater.update_all_stats() updater.shutdown() if args.testing: logging.info('Stopping Mongo Server...') mongo_server.shutdown() return 0
def main(command_line_options=None): command_line_options = sys.argv if command_line_options is None else command_line_options args, config = program_setup(PROGRAM_NAME, PROGRAM_DESCRIPTION, command_line_options=command_line_options) logging.info('Try to start Mongo Server...') mongo_server = MongoMgr(config=config) logging.info('updating data... this may take several hours depending on the size of your database') start_time = time() return_code = _create_variety_data(config) process_time = time() - start_time logging.info('generation time: {}'.format(time_format(process_time))) if args.testing: logging.info('Stopping Mongo Server...') mongo_server.shutdown() return return_code
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)
def setUpClass(cls): cls._config = get_config_for_testing() cls.mongo_server = MongoMgr(config=cls._config)
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)
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)
def convert_comments_to_new_format(db_service): for collection in [db_service.firmwares, db_service.file_objects]: comment_query = collection.find({"comments": {"$type": "object"}}, {"_id": 1, "comments": 1}) for entry in comment_query: firmware_id = entry["_id"] comment_field = entry["comments"] if type(comment_field) == dict: logging.debug("converting comments of {}".format(firmware_id)) try: updated_comment_field = [ {"time": time, "author": comment_field[time][0], "comment": comment_field[time][1]} for time in comment_field ] db_service.update_object_field(firmware_id, "comments", updated_comment_field) except Exception as e: logging.error("could not convert comment entry: {} {}".format(sys.exc_info()[0].__name__, e)) if __name__ == '__main__': args = _setup_argparser() config = _load_config(args) _setup_logging() logging.info("Trying to start Mongo Server and initializing users...") mongo_manger = MongoMgr(config=config, auth=False) db_service_frontend_editing = FrontendEditingDbInterface(config) convert_comments_to_new_format(db_service_frontend_editing) convert_release_dates_to_date_object_format(db_service_frontend_editing) add_parent_firmware_list_to_file_object(db_service_frontend_editing)
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()
def setUpClass(cls): cls._set_config() cls.mongo_server = MongoMgr(config=cls.config)
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)
def __init__(self): _, config = program_setup(self.PROGRAM_NAME, self.PROGRAM_DESCRIPTION, self.COMPONENT) self.mongo_server = MongoMgr(config=config) super().__init__()
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)
def test_server(test_config): mongo = MongoMgr(test_config) clean_test_database(test_config, get_database_names(test_config)) yield None clean_test_database(test_config, get_database_names(test_config)) mongo.shutdown()
def setUpClass(cls): cls.config = get_config_for_testing(TMP_DIR) cls.mongo_mgr = MongoMgr(cls.config)
username=config['data_storage']['db_admin_user'], password=config['data_storage']['db_admin_pw'], main_database=config['data_storage']['main_database'], script_path=full_variety_path), timeout=None) logging.debug(output) return return_code if __name__ == '__main__': args = _setup_argparser() config = _load_config(args) _setup_logging(args) logging.info('Try to start Mongo Server...') mongo_server = MongoMgr(config=config) logging.info( 'updating data... this may take several hours depending on the size of your database' ) start_time = time() return_code = _create_variety_data(config) process_time = time() - start_time logging.info('generation time: {}'.format(time_format(process_time))) if args.shutdown_db: logging.info('Stopping Mongo Server...') mongo_server.shutdown() sys.exit(return_code)