Skip to content

Commit 999b3fe

Browse files
authored
fix: replace shell=True subprocess with argument list in modal CLI (#3487)
* fix: replace shell=True subprocess with argument list in modal CLI Using shell=True with a formatted string containing docker_image (a user-controlled value) is a command injection risk (Bandit B602). Replace with an argument list, which passes args directly to the process without shell interpretation, removing the nosec annotation. * fix: add nosec annotation to suppress bandit B603/B607 warnings Removing shell=True (B602) surfaces B603 (subprocess without shell) and B607 (partial executable path for 'docker'). Use bare # nosec to suppress both, consistent with other nosec usages in the codebase.
1 parent 8f3fb51 commit 999b3fe

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/axolotl/cli/cloud/modal_.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ def get_image(self):
9090
# grab the sha256 hash from docker hub for this image+tag
9191
# this ensures that we always get the latest image for this tag, even if it's already cached
9292
try:
93-
manifest = subprocess.check_output( # nosec B602
94-
f"docker manifest inspect {docker_image}",
95-
shell=True,
93+
manifest = subprocess.check_output( # nosec
94+
["docker", "manifest", "inspect", docker_image],
9695
).decode("utf-8")
9796
sha256_hash = json.loads(manifest)["manifests"][0]["digest"]
9897
except subprocess.CalledProcessError:

0 commit comments

Comments
 (0)