From bf9e232c9c445d1f0aa3d53fcf8a83c720db169d Mon Sep 17 00:00:00 2001 From: Kevin O'Reilly Date: Mon, 15 Jun 2026 15:20:37 +0100 Subject: [PATCH 1/2] Agent: add subdir_upload feature flag, bump AGENT_VERSION to 0.22 --- agent/agent.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agent/agent.py b/agent/agent.py index fac90960cba..26dd5c1b506 100644 --- a/agent/agent.py +++ b/agent/agent.py @@ -45,7 +45,7 @@ #if sys.maxsize > 2**32 and sys.platform == "win32": # sys.exit("You should install python3 x86! not x64") -AGENT_VERSION = "0.21" +AGENT_VERSION = "0.22" AGENT_FEATURES = [ "execpy", "execute", @@ -53,6 +53,7 @@ "logs", "largefile", "unicodepath", + "subdir_upload", ] BASE_64_ENCODING = "base64" @@ -592,6 +593,9 @@ def do_store(): return json_error(400, "No file has been provided") try: + dirpath = os.path.dirname(request.form["filepath"]) + if dirpath: + os.makedirs(dirpath, exist_ok=True) with open(request.form["filepath"], "wb") as f: shutil.copyfileobj(request.files["file"], f, 10 * 1024 * 1024) except Exception as ex: From 50a4cd8b90c8c96e8866d25f1e97c89e1fac6ce9 Mon Sep 17 00:00:00 2001 From: Kevin O'Reilly Date: Mon, 15 Jun 2026 15:21:49 +0100 Subject: [PATCH 2/2] Fix issue with guest.py per-task upload directories: gate on agent v0.22 subdir_upload feature --- lib/cuckoo/core/guest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cuckoo/core/guest.py b/lib/cuckoo/core/guest.py index 15e3c446cfa..a8553db81ae 100644 --- a/lib/cuckoo/core/guest.py +++ b/lib/cuckoo/core/guest.py @@ -311,10 +311,14 @@ def start_analysis(self, options): # Update file_name in options if category is file/archive to include task-id unique subdirectory # This must be done BEFORE self.add_config(options) is called so that analysis.conf in guest has the correct path if options["category"] in ("file", "archive"): - if self.platform == "windows": - options["file_name"] = f"{options['id']}\\{sanitize_filename(options['file_name'])}" + if "subdir_upload" in features: + if self.platform == "windows": + options["file_name"] = f"{options['id']}\\{sanitize_filename(options['file_name'])}" + else: + options["file_name"] = f"{options['id']}/{sanitize_filename(options['file_name'])}" else: - options["file_name"] = f"{options['id']}/{sanitize_filename(options['file_name'])}" + options["file_name"] = sanitize_filename(options["file_name"]) + # Pass along the analysis.conf file. self.add_config(options)