From c58797103bd786a0e977744f8cd323b8a058705d Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Tue, 22 Apr 2025 23:03:18 +0530 Subject: [PATCH 1/4] output stderr when running ssh commands --- shuffle-tools/1.2.0/src/app.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shuffle-tools/1.2.0/src/app.py b/shuffle-tools/1.2.0/src/app.py index 4707538c..6ae688cd 100644 --- a/shuffle-tools/1.2.0/src/app.py +++ b/shuffle-tools/1.2.0/src/app.py @@ -2632,6 +2632,11 @@ def run_ssh_command(self, host, port, user_name, private_key_file_id, password, try: stdin, stdout, stderr = ssh_client.exec_command(str(command)) + + stderr_ouput = stderr.read().decode(errors='ignore') + + if stderr_ouput: + return {"success": "true", "message": stderr_ouput} except Exception as e: return {"success":"false","message":str(e)} From 3f2bd418265e2096fb3aa941ce1934e0a09f7934 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Mon, 5 May 2025 19:09:34 +0530 Subject: [PATCH 2/4] provide stderr for ssh commands --- shuffle-tools/1.2.0/src/app.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shuffle-tools/1.2.0/src/app.py b/shuffle-tools/1.2.0/src/app.py index 6ae688cd..233e1aab 100644 --- a/shuffle-tools/1.2.0/src/app.py +++ b/shuffle-tools/1.2.0/src/app.py @@ -2633,14 +2633,10 @@ def run_ssh_command(self, host, port, user_name, private_key_file_id, password, try: stdin, stdout, stderr = ssh_client.exec_command(str(command)) - stderr_ouput = stderr.read().decode(errors='ignore') - - if stderr_ouput: - return {"success": "true", "message": stderr_ouput} except Exception as e: return {"success":"false","message":str(e)} - return {"success":"true","output": stdout.read().decode(errors='ignore')} + return {"success":"true","output": stdout.read().decode(errors='ignore'), "error_log": stderr.read().decode(errors='ignore')} def cleanup_ioc_data(self, input_data): # Remove unecessary parts like { and }, quotes etc From de2914ee5179b8734e61287a1957af2d7bc770fd Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Mon, 5 May 2025 19:10:38 +0530 Subject: [PATCH 3/4] fixed grammar --- shuffle-tools/1.2.0/src/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shuffle-tools/1.2.0/src/app.py b/shuffle-tools/1.2.0/src/app.py index 233e1aab..ecdf1630 100644 --- a/shuffle-tools/1.2.0/src/app.py +++ b/shuffle-tools/1.2.0/src/app.py @@ -2636,7 +2636,7 @@ def run_ssh_command(self, host, port, user_name, private_key_file_id, password, except Exception as e: return {"success":"false","message":str(e)} - return {"success":"true","output": stdout.read().decode(errors='ignore'), "error_log": stderr.read().decode(errors='ignore')} + return {"success":"true","output": stdout.read().decode(errors='ignore'), "error_logs": stderr.read().decode(errors='ignore')} def cleanup_ioc_data(self, input_data): # Remove unecessary parts like { and }, quotes etc From efafb3f11eb132d11f9d6255d57340e802407647 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Tue, 10 Jun 2025 18:04:31 +0530 Subject: [PATCH 4/4] added try-catch in output and error_log --- shuffle-tools/1.2.0/src/app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shuffle-tools/1.2.0/src/app.py b/shuffle-tools/1.2.0/src/app.py index ecdf1630..78e84860 100644 --- a/shuffle-tools/1.2.0/src/app.py +++ b/shuffle-tools/1.2.0/src/app.py @@ -2632,11 +2632,19 @@ def run_ssh_command(self, host, port, user_name, private_key_file_id, password, try: stdin, stdout, stderr = ssh_client.exec_command(str(command)) + try: + errorLog = stderr.read().decode(errors='ignore') + except Exception as e: + errorLog = f"Failed to read stderr {e}" + try: + output = stdout.read().decode(errors='ignore') + except Exception as e: + output = f"Failed to read stdout {e}" except Exception as e: return {"success":"false","message":str(e)} - return {"success":"true","output": stdout.read().decode(errors='ignore'), "error_logs": stderr.read().decode(errors='ignore')} + return {"success":"true","output": output, "error_logs": errorLog} def cleanup_ioc_data(self, input_data): # Remove unecessary parts like { and }, quotes etc