Best Python code snippet using lisa_python
lab.py
Source:lab.py
...133 """134 # TODO: Import events from fs135 if not self.__run_on_this_instance:136 return137 self.__api.set_server_setting("Plugin.Enrichment_services_enable", True, True)138 self.__api.set_server_setting("Plugin.Enrichment_hover_enable", True, True)139 self.__api.set_server_setting("Plugin.Enrichment_geoip_city_enabled", True, True)140 self.__api.set_server_setting("Plugin.Enrichment_geoip_city_restrict", 6, True)141 self.__api.set_server_setting("Plugin.Enrichment_geoip_city_local_geolite_db", "/data-shared/geolite/city.mmdb",142 True)143 self.__api.set_server_setting("Plugin.Enrichment_btc_scam_check_enabled", True, True)144 self.__api.set_server_setting("Plugin.Enrichment_btc_scam_check_restrict", 6, True)145 self.__api.set_server_setting("Plugin.Enrichment_macvendors_enabled", True, True)146 self.__api.set_server_setting("Plugin.Enrichment_macvendors_restrict", 6, True)147 self.__api.set_server_setting("Plugin.Enrichment_qrcode_enabled", True, True)148 self.__api.set_server_setting("Plugin.Enrichment_qrcode_restrict", 6, True)149 self.__api.set_server_setting("Plugin.Enrichment_urlhaus_enabled", True, True)150 self.__api.set_server_setting("Plugin.Enrichment_urlhaus_restrict", 6, True)151 def get_org(self, pos: int = 0):152 """153 Get default or specific org154 :param pos: Position in the org dict155 :return: Org name and id156 :rtype: dict157 """158 if not self.__run_on_this_instance:159 return160 return self.__orgs[pos]161 def get_admin(self, pos: int = 0):162 """163 Get the admin account for that lab164 :param pos: Position in the admin dict...
configuration.py
Source:configuration.py
...27 misp.enable_taxonomy(119) # tlp28 misp.enable_taxonomy_tags(119)29 misp.update_warninglists()30def set_server_settings():31 misp.set_server_setting("Security.password_policy_length", 7, True)32 misp.set_server_setting("Security.password_policy_complexity", "/(a-z)*/", True)33 misp.set_server_setting("MISP.main_logo", "logo.png", True)34 misp.set_server_setting("MISP.welcome_text_top", "Welcome to Malware Information Sharing Platform ", True)35x = True36while x:37 try:38 time.sleep(10)39 get_vital_signs()40 misp_key = get_api_key('admin@admin.test')41 new_admin_api(misp_key)42 x = False43 except:44 x = True45update_instance()46set_server_settings()47# -------------------- LAB CONFIGURATION -------------------- #48# Lab 0: Instance Admin Configuration...
TeraServerSettings.py
Source:TeraServerSettings.py
...17 @staticmethod18 def create_defaults(test=False):19 # Create defaults settings20 # Token Encryption Key21 TeraServerSettings.set_server_setting(TeraServerSettings.ServerDeviceTokenKey,22 TeraServerSettings.generate_token_key(32))23 TeraServerSettings.set_server_setting(TeraServerSettings.ServerParticipantTokenKey,24 TeraServerSettings.generate_token_key(32))25 # Unique server id26 server_uuid = str(uuid.uuid4())27 TeraServerSettings.set_server_setting(TeraServerSettings.ServerUUID, server_uuid)28 @staticmethod29 def generate_token_key(length: int) -> str:30 token_symbols = digits + ascii_uppercase + ascii_lowercase31 token_key = ''.join(random.choice(token_symbols) for i in range(length)) # Key length = 32 chars32 return token_key33 @staticmethod34 def get_server_setting_value(setting_name: string):35 current_setting = TeraServerSettings.get_server_setting(setting_name=setting_name)36 if current_setting:37 return current_setting.server_settings_value38 else:39 return None40 @staticmethod41 def get_server_setting(setting_name: string):42 return TeraServerSettings.query.filter_by(server_settings_name=setting_name).first()43 @staticmethod44 def set_server_setting(setting_name: string, setting_value: string):45 # Check if setting already exists46 current_setting = TeraServerSettings.get_server_setting(setting_name=setting_name)47 # Update setting if already exists48 if current_setting is not None:49 current_setting.server_settings_value = setting_value50 else:51 # Insert setting if not52 current_setting = TeraServerSettings()53 current_setting.id_server_settings = None54 current_setting.server_settings_name = setting_name55 current_setting.server_settings_value = setting_value56 db.session.add(current_setting)57 # Store object58 current_setting.commit()
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!