Skip to content

Commit ed82027

Browse files
icywang86ruiRui Wang Napieralski
andauthored
fix: remove shell=True in subprocess.check_output (#2069)
Co-authored-by: Rui Wang Napieralski <[email protected]>
1 parent d2c317d commit ed82027

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/sagemaker/local/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ def _ecr_login_if_needed(boto_session, image):
10671067
ecr_url = auth["authorizationData"][0]["proxyEndpoint"]
10681068

10691069
cmd = "docker login -u AWS -p %s %s" % (token, ecr_url)
1070-
subprocess.check_output(cmd, shell=True)
1070+
subprocess.check_output(cmd.split())
10711071

10721072
return True
10731073

@@ -1081,5 +1081,5 @@ def _pull_image(image):
10811081
pull_image_command = ("docker pull %s" % image).strip()
10821082
logger.info("docker command: %s", pull_image_command)
10831083

1084-
subprocess.check_output(pull_image_command, shell=True)
1084+
subprocess.check_output(pull_image_command.split())
10851085
logger.info("image pulled: %s", image)

tests/unit/test_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ def test_ecr_login_needed(check_output):
765765
"docker login -u AWS -p %s https://520713654638.dkr.ecr.us-east-1.amazonaws.com" % token
766766
)
767767

768-
check_output.assert_called_with(expected_command, shell=True)
768+
check_output.assert_called_with(expected_command.split())
769769
session_mock.client("ecr").get_authorization_token.assert_called_with(
770770
registryIds=["520713654638"]
771771
)
@@ -781,7 +781,7 @@ def test_pull_image(check_output):
781781

782782
expected_command = "docker pull %s" % image
783783

784-
check_output.assert_called_once_with(expected_command, shell=True)
784+
check_output.assert_called_once_with(expected_command.split())
785785

786786

787787
def test__aws_credentials_with_long_lived_credentials():

0 commit comments

Comments
 (0)