Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfed5ea6

Browse files
author
patched.codes[bot]
committed
Patched /tmp/tmpi4bo6m70/main.py
1 parent4964f26 commitfed5ea6

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

‎main.py‎

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
1+
A.Commitmessage:
2+
Fixsecurityvulnerabilityinsubprocesscall
3+
4+
B.Changesummary:
5+
Removedtheuseof`shell=True`inthe`subprocess.call`.Updatedtoexecutethecommandwithoutinvokingashell,whichpreventscommandinjectionvulnerabilities.
6+
7+
C.CompatibilityRisk:
8+
Medium
9+
10+
D.FixedCode:
11+
```
112
importrequests
213
importsubprocess
314

15+
416
deffunc_calls():
5-
formats.get_format()
6-
algorithms.HMACAlgorithm.prepare_key()
7-
cli.VerifyOperation.perform_operation()
8-
sessions.SessionRedirectMixin.resolve_redirects()
17+
formats.get_format()
18+
algorithms.HMACAlgorithm.prepare_key()
19+
cli.VerifyOperation.perform_operation()
20+
sessions.SessionRedirectMixin.resolve_redirects()
21+
922

1023
if__name__=='__main__':
11-
session=requests.Session()
12-
proxies= {
13-
'http':'http://test:pass@localhost:8080',
14-
'https':'http://test:pass@localhost:8090',
15-
}
16-
url='http://example.com'# Replace with a valid URL
17-
req=requests.Request('GET',url)
18-
prep=req.prepare()
19-
session.rebuild_proxies(prep,proxies)
20-
21-
# Introduce a command injection vulnerability
22-
user_input=input("Enter a command to execute: ")
23-
command="ping "+user_input
24-
subprocess.call(command,shell=True)
25-
26-
print("Command executed!")
24+
session=requests.Session()
25+
proxies= {
26+
'http':'http://test:pass@localhost:8080',
27+
'https':'http://test:pass@localhost:8090',
28+
}
29+
url='http://example.com'# Replace with a valid URL
30+
req=requests.Request('GET',url)
31+
prep=req.prepare()
32+
session.rebuild_proxies(prep,proxies)
33+
34+
# Removed command injection vulnerability
35+
user_input=input("Enter a command to execute: ")
36+
command= ["ping",user_input]
37+
subprocess.call(command,shell=False)
38+
39+
print("Command executed!")
40+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp