10
10
def command_injection1 ():
11
11
files = request .args .get ('files' , '' )
12
12
# Don't let files be `; rm -rf /`
13
- os .system ("ls " + files ) # $flow="ImportMember, l:-8 -> BinaryExpr"
13
+ os .system ("ls " + files ) # $result=BAD
14
14
15
15
16
16
@app .route ("/command2" )
17
17
def command_injection2 ():
18
18
files = request .args .get ('files' , '' )
19
19
# Don't let files be `; rm -rf /`
20
- subprocess .Popen ("ls " + files , shell = True ) # $flow="ImportMember, l:-15 -> BinaryExpr"
20
+ subprocess .Popen ("ls " + files , shell = True ) # $result=BAD
21
21
22
22
23
23
@app .route ("/command3" )
24
24
def first_arg_injection ():
25
25
cmd = request .args .get ('cmd' , '' )
26
- subprocess .Popen ([cmd , "param1" ]) # $flow="ImportMember, l:-21 -> cmd"
26
+ subprocess .Popen ([cmd , "param1" ]) # $result=BAD
27
27
28
28
29
29
@app .route ("/other_cases" )
30
30
def others ():
31
31
files = request .args .get ('files' , '' )
32
32
# Don't let files be `; rm -rf /`
33
- os .popen ("ls " + files ) # $flow="ImportMember, l:-28 -> BinaryExpr"
33
+ os .popen ("ls " + files ) # $result=BAD
34
34
35
35
36
36
@app .route ("/multiple" )
37
37
def multiple ():
38
38
command = request .args .get ('command' , '' )
39
39
# We should mark flow to both calls here, which conflicts with removing flow out of
40
40
# a sink due to use-use flow.
41
- os .system (command ) # $flow="ImportMember, l:-36 -> command"
42
- os .system (command ) # $flow="ImportMember, l:-37 -> command"
41
+ os .system (command ) # $result=BAD
42
+ os .system (command ) # $result=BAD
43
43
44
44
45
45
@app .route ("/not-into-sink-impl" )
@@ -52,11 +52,11 @@ def not_into_sink_impl():
52
52
subprocess.call implementation: https://github.com/python/cpython/blob/fa7ce080175f65d678a7d5756c94f82887fc9803/Lib/subprocess.py#L341
53
53
"""
54
54
command = request .args .get ('command' , '' )
55
- os .system (command ) # $flow="ImportMember, l:-50 -> command"
56
- os .popen (command ) # $flow="ImportMember, l:-51 -> command"
57
- subprocess .call (command ) # $flow="ImportMember, l:-52 -> command"
58
- subprocess .check_call (command ) # $flow="ImportMember, l:-53 -> command"
59
- subprocess .run (command ) # $flow="ImportMember, l:-54 -> command"
55
+ os .system (command ) # $result=BAD
56
+ os .popen (command ) # $result=BAD
57
+ subprocess .call (command ) # $result=BAD
58
+ subprocess .check_call (command ) # $result=BAD
59
+ subprocess .run (command ) # $result=BAD
60
60
61
61
62
62
@app .route ("/path-exists-not-sanitizer" )
@@ -70,11 +70,11 @@ def path_exists_not_sanitizer():
70
70
"""
71
71
path = request .args .get ('path' , '' )
72
72
if os .path .exists (path ):
73
- os .system ("ls " + path ) # $flow="ImportMember, l:-68 -> BinaryExpr"
73
+ os .system ("ls " + path ) # $result=BAD
74
74
75
75
76
76
@app .route ("/restricted-characters" )
77
77
def restricted_characters ():
78
78
path = request .args .get ('path' , '' )
79
79
if re .match (r'^[a-zA-Z0-9_-]+$' , path ):
80
- os .system ("ls " + path ) # $SPURIOUS: flow="ImportMember, l:-75 -> BinaryExpr"
80
+ os .system ("ls " + path ) # $SPURIOUS: result=BAD
0 commit comments