From a9a006a9fd78562402c7cf0384dea714d8255070 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 30 Aug 2022 12:30:10 +0530 Subject: [PATCH] Agent: Replace fields in configuration using pydantic syntax in PBA file upload resource --- monkey/monkey_island/cc/resources/pba_file_upload.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index c62272e7c..d76b8665a 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -1,5 +1,4 @@ import logging -from dataclasses import replace from http import HTTPStatus from flask import Response, make_response, request, send_file @@ -102,11 +101,15 @@ class PBAFileUpload(AbstractResource): agent_configuration = self._agent_configuration_repository.get_configuration() if target_os == LINUX_PBA_TYPE: - custom_pbas = replace(agent_configuration.custom_pbas, linux_filename=safe_filename) + custom_pbas = agent_configuration.custom_pbas.copy( + update={"linux_filename": safe_filename} + ) else: - custom_pbas = replace(agent_configuration.custom_pbas, windows_filename=safe_filename) + custom_pbas = agent_configuration.custom_pbas.copy( + update={"windows_filename": safe_filename} + ) - updated_agent_configuration = replace(agent_configuration, custom_pbas=custom_pbas) + updated_agent_configuration = agent_configuration.copy(update={"custom_pbas": custom_pbas}) self._agent_configuration_repository.store_configuration(updated_agent_configuration) @jwt_required