def apply_to_monkey_config(): """ Applies ATT&CK matrix to the monkey configuration :return: """ attack_techniques = AttackConfig.get_technique_values() monkey_config = ConfigService.get_config(False, True, True) monkey_schema = ConfigService.get_config_schema() AttackConfig.set_arrays(attack_techniques, monkey_config, monkey_schema) AttackConfig.set_booleans(attack_techniques, monkey_config, monkey_schema) ConfigService.update_config(monkey_config, True)
def post(self): request_contents = json.loads(request.data) try: config = ConfigurationImport._get_plaintext_config_from_request(request_contents) if request_contents["unsafeOptionsVerified"]: ConfigurationImport.import_config(config) return ResponseContents().form_response() else: return ResponseContents( config=json.dumps(config), config_schema=ConfigService.get_config_schema(), import_status=ImportStatuses.UNSAFE_OPTION_VERIFICATION_REQUIRED, ).form_response() except InvalidCredentialsError: return ResponseContents( import_status=ImportStatuses.INVALID_CREDENTIALS, message="Invalid credentials provided", ).form_response() except InvalidConfigurationError: return ResponseContents( import_status=ImportStatuses.INVALID_CONFIGURATION, message="Invalid configuration supplied. " "Maybe the format is outdated or the file has been corrupted.", ).form_response()
def get(self): return jsonify( schema=ConfigService.get_config_schema(), configuration=ConfigService.get_config(False, True), )