@@ -52,28 +52,45 @@ def test_shell_exec_ok(s):
5252@pytest .mark .parametrize (
5353 's, msg_id' ,
5454 (
55- ('os.system("ls -l")' , flake8_scs .SCS102 ),
56- ('from os import system' , flake8_scs .SCS102 ),
57- ('from os import system as os_system' , flake8_scs .SCS102 ),
58- ('from os import popen' , flake8_scs .SCS110 ),
59- ('from os import popen as os_popen' , flake8_scs .SCS110 ),
60- ('subprocess.Popen(["cat", "/etc/passwd"], b, e, i, o, e, pre, c, True)' , flake8_scs .SCS103 ),
61- ('subprocess.Popen(["cat", "/etc/passwd"], b, e, i, o, e, pre, c, True, cwd)' , flake8_scs .SCS103 ),
62- ('subprocess.run(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
63- ('sp.run(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
64- ('subprocess.call(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
65- ('sp.call(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
66- ('subprocess.check_call(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
67- ('sp.check_call(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
68- ('subprocess.check_output(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
69- ('sp.check_output(["cat", "/etc/passwd"], shell=True)' , flake8_scs .SCS103 ),
70- ('os.popen("cat")' , flake8_scs .SCS110 ),
71- ('os.popen("cat", "r")' , flake8_scs .SCS110 ),
72- ('os.popen("cat", "r", 1)' , flake8_scs .SCS110 ),
73- ('os.popen("cat", buffering=1)' , flake8_scs .SCS110 ),
74- ('os.popen("cat", mode="w")' , flake8_scs .SCS110 ),
75- ('os.popen("cat", mode="w", buffering=1)' , flake8_scs .SCS110 ),
55+ ('os.system("ls -l")' , 'SCS102' ),
56+ ('from os import system' , 'SCS102' ),
57+ ('from os import system as os_system' , 'SCS102' ),
58+ ('from os import popen' , 'SCS110' ),
59+ ('from os import popen as os_popen' , 'SCS110' ),
60+ ('from subprocess import getoutput' , 'SCS103' ),
61+ ('from subprocess import getoutput as sp_getoutput' , 'SCS103' ),
62+ ('from subprocess import getstatusoutput' , 'SCS103' ),
63+ ('from subprocess import getstatusoutput as sp_getstatusoutput' , 'SCS103' ),
64+ ('from asyncio import create_subprocess_shell' , 'SCS103' ),
65+ ('from asyncio import create_subprocess_shell as create_sp_shell' , 'SCS103' ),
66+ ('subprocess.Popen(["cat", "/etc/passwd"], b, e, i, o, e, pre, c, True)' , 'SCS103' ),
67+ ('subprocess.Popen(["cat", "/etc/passwd"], b, e, i, o, e, pre, c, True, cwd)' , 'SCS103' ),
68+ ('subprocess.run(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
69+ ('sp.run(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
70+ ('subprocess.call(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
71+ ('sp.call(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
72+ ('subprocess.check_call(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
73+ ('sp.check_call(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
74+ ('subprocess.check_output(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
75+ ('sp.check_output(["cat", "/etc/passwd"], shell=True)' , 'SCS103' ),
76+ ('subprocess.getoutput("ls /bin/ls")' , 'SCS103' ),
77+ ('sp.getoutput("ls /bin/ls")' , 'SCS103' ),
78+ ('subprocess.getstatusoutput("ls /bin/ls")' , 'SCS103' ),
79+ ('sp.getstatusoutput("ls /bin/ls")' , 'SCS103' ),
80+ ('asyncio.create_subprocess_shell("ls /bin/ls")' , 'SCS103' ),
81+ ('asyncio.create_subprocess_shell(cmd)' , 'SCS103' ),
82+ ('asyncio.create_subprocess_shell("ls /bin/ls", stdin=PIPE, stdout=PIPE)' , 'SCS103' ),
83+ ('asyncio.create_subprocess_shell(cmd, stdin=PIPE, stdout=PIPE)' , 'SCS103' ),
84+ ('loop.subprocess_shell(asyncio.SubprocessProtocol, "ls /bin/ls")' , 'SCS103' ),
85+ ('loop.subprocess_shell(asyncio.SubprocessProtocol, cmd)' , 'SCS103' ),
86+ ('loop.subprocess_shell(asyncio.SubprocessProtocol, cmd, **kwds)' , 'SCS103' ),
87+ ('os.popen("cat")' , 'SCS110' ),
88+ ('os.popen("cat", "r")' , 'SCS110' ),
89+ ('os.popen("cat", "r", 1)' , 'SCS110' ),
90+ ('os.popen("cat", buffering=1)' , 'SCS110' ),
91+ ('os.popen("cat", mode="w")' , 'SCS110' ),
92+ ('os.popen("cat", mode="w", buffering=1)' , 'SCS110' ),
7693 ),
7794)
7895def test_shell_exec_not_ok (s , msg_id ):
79- assert results (s ) == {'1:0: ' + msg_id }
96+ assert results (s ) == {'1:0: ' + getattr ( flake8_scs , msg_id ) }
0 commit comments