Skip to content

Commit 3622aac

Browse files
authored
Remove shell=True (#300)
Signed-off-by: maipbui <[email protected]> Signed-off-by: maipbui <[email protected]>
1 parent 143422b commit 3622aac

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sonic-pcied/tests/mocked_libs/sonic_platform_base/sonic_pcie/pcie_common.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def get_pcie_device(self):
3939
pciList = []
4040
p1 = "^(\w+):(\w+)\.(\w)\s(.*)\s*\(*.*\)*"
4141
p2 = "^.*:.*:.*:(\w+)\s*\(*.*\)*"
42-
command1 = "sudo lspci"
43-
command2 = "sudo lspci -n"
42+
command1 = ["sudo", "lspci"]
43+
command2 = ["sudo", "lspci", "-n"]
4444
# run command 1
45-
proc1 = subprocess.Popen(command1, shell=True, universal_newlines=True, stdout=subprocess.PIPE)
45+
proc1 = subprocess.Popen(command1, universal_newlines=True, stdout=subprocess.PIPE)
4646
output1 = proc1.stdout.readlines()
4747
(out, err) = proc1.communicate()
4848
# run command 2
49-
proc2 = subprocess.Popen(command2, shell=True, universal_newlines=True, stdout=subprocess.PIPE)
49+
proc2 = subprocess.Popen(command2, universal_newlines=True, stdout=subprocess.PIPE)
5050
output2 = proc2.stdout.readlines()
5151
(out, err) = proc2.communicate()
5252

sonic-xcvrd/xcvrd/xcvrd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def is_fast_reboot_enabled():
907907
keys = fastboot_tbl.getKeys()
908908

909909
if "system" in keys:
910-
output = subprocess.check_output('sonic-db-cli STATE_DB get "FAST_REBOOT|system"', shell=True, universal_newlines=True)
910+
output = subprocess.check_output(['sonic-db-cli', 'STATE_DB', 'get', "FAST_REBOOT|system"], universal_newlines=True)
911911
if "1" in output:
912912
fastboot_enabled = True
913913

0 commit comments

Comments
 (0)