From 612a8ef07db919935b9fe2a7f90f44b08aa4d68b Mon Sep 17 00:00:00 2001 From: "patched.codes[bot]" <298395+patched.codes[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:47:01 -0700 Subject: [PATCH 1/3] Patched /Users/user/Documents/GitHub/example-python/main.py --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 468f8c0..55c4ba4 100644 --- a/main.py +++ b/main.py @@ -13,14 +13,14 @@ def func_calls(): 'http': 'http://test:pass@localhost:8080', 'https': 'http://test:pass@localhost:8090', } - url = 'http://example.com' # Replace with a valid URL + url = 'https://example.com' # Replace with a valid URL req = requests.Request('GET', url) prep = req.prepare() session.rebuild_proxies(prep, proxies) # Introduce a command injection vulnerability user_input = input("Enter a command to execute: ") - command = "ping " + user_input - subprocess.call(command, shell=True) + command = ["ping", user_input] + subprocess.call(command, shell=False) - print("Command executed!") \ No newline at end of file + print("Command executed!") From 9a0a2dbead792b3bdc8a020c25f7cf5914c1d58c Mon Sep 17 00:00:00 2001 From: "patched.codes[bot]" <298395+patched.codes[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:24:21 +0000 Subject: [PATCH 2/3] Patched /tmp/tmpghkshy1r/main.py --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 55c4ba4..37fd7f1 100644 --- a/main.py +++ b/main.py @@ -18,9 +18,9 @@ def func_calls(): prep = req.prepare() session.rebuild_proxies(prep, proxies) - # Introduce a command injection vulnerability + # Fix command injection vulnerability user_input = input("Enter a command to execute: ") command = ["ping", user_input] - subprocess.call(command, shell=False) + subprocess.Popen(command, shell=False) print("Command executed!") From a7aad2a34a10a10f030d08c7685979f5bda0228f Mon Sep 17 00:00:00 2001 From: "patched.codes[bot]" <298395+patched.codes[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:25:02 +0000 Subject: [PATCH 3/3] Patched /tmp/tmp4h9js25h/main.py --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 37fd7f1..4a9f098 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import requests import subprocess +import shlex def func_calls(): formats.get_format() @@ -20,7 +21,7 @@ def func_calls(): # Fix command injection vulnerability user_input = input("Enter a command to execute: ") - command = ["ping", user_input] + command = ["ping"] + shlex.split(user_input) subprocess.Popen(command, shell=False) print("Command executed!")