Skip to content

Commit 437c15b

Browse files
author
patched.codes[bot]
committed
Patched: "/tmp/tmpnly81dlr/main.py"
1 parent 9e553e4 commit 437c15b

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
if __name__ == '__main__':
56
formats.get_format()
@@ -9,16 +10,17 @@
910
session = requests.Session()
1011
proxies = {
1112
'http': 'http://test:pass@localhost:8080',
12-
'https': 'http://test:pass@localhost:8090',
13+
'https': 'https://test:pass@localhost:8090', # Changed to HTTPS
1314
}
14-
url = 'http://example.com' # Replace with a valid URL
15+
url = 'https://example.com' # Changed to HTTPS and replace with a valid URL
1516
req = requests.Request('GET', url)
1617
prep = req.prepare()
1718
session.rebuild_proxies(prep, proxies)
1819

19-
# Introduce a command injection vulnerability
20+
# Fix for command injection vulnerability
2021
user_input = input("Enter a command to execute: ")
21-
command = "ping " + user_input
22+
safe_user_input = shlex.quote(user_input)
23+
command = "ping " + safe_user_input
2224
subprocess.call(command, shell=True)
2325

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

0 commit comments

Comments
 (0)