Skip to content

Commit bc0855c

Browse files
committed
Fix unsafe shell command in luigi/contrib/lsf.py
Fixes #3304 Update `track_job` function to use `shell=False` in `subprocess.Popen` call. * Change the `cmd` variable to be a list of arguments instead of a single string. * Set the `shell` parameter to `False` in the `subprocess.Popen` call.
1 parent 74e6e63 commit bc0855c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

luigi/contrib/lsf.py

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def track_job(job_id):
8181
- "EXIT"
8282
based on the LSF documentation
8383
"""
84-
cmd = "bjobs -noheader -o stat {}".format(job_id)
84+
cmd = ["bjobs", "-noheader", "-o", "stat", str(job_id)]
8585
track_job_proc = subprocess.Popen(
86-
cmd, stdout=subprocess.PIPE, shell=True)
86+
cmd, stdout=subprocess.PIPE, shell=False)
8787
status = track_job_proc.communicate()[0].strip('\n')
8888
return status
8989

0 commit comments

Comments
 (0)