Skip to content

Commit 270fa50

Browse files
author
patched.codes[bot]
committed
Patched: "/tmp/tmpakmhwdfh/main.py"
1 parent e24fb58 commit 270fa50

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
import subprocess
3+
import shlex
34

45
def func_calls():
56
formats.get_format()
@@ -11,16 +12,17 @@ def func_calls():
1112
session = requests.Session()
1213
proxies = {
1314
'http': 'http://test:pass@localhost:8080',
14-
'https': 'http://test:pass@localhost:8090',
15+
'https': 'https://test:pass@localhost:8090', # Changed http to https for secure transmission
1516
}
16-
url = 'http://example.com' # Replace with a valid URL
17+
url = 'https://example.com' # Changed http to https for secure transmission
1718
req = requests.Request('GET', url)
1819
prep = req.prepare()
1920
session.rebuild_proxies(prep, proxies)
2021

21-
# Introduce a command injection vulnerability
22+
# Fix for command injection vulnerability
2223
user_input = input("Enter a command to execute: ")
23-
command = "ping " + user_input
24+
safe_user_input = shlex.quote(user_input)
25+
command = "ping " + safe_user_input
2426
subprocess.call(command, shell=True)
2527

26-
print("Command executed!")
28+
print("Command executed!")

0 commit comments

Comments
 (0)