Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scripts/check-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.

import platform
import shlex
import subprocess
import sys
from typing import Callable, Optional, Set, Tuple
Expand Down Expand Up @@ -47,11 +48,11 @@ def __init__(

def get_version(self) -> Optional[str]:
try:
version = subprocess.check_output(self.command, shell=True).decode().strip() # noqa: S602
version = subprocess.check_output(shlex.split(self.command)).decode().strip()
if self.version_post_process:
version = self.version_post_process(version)
return version.split()[-1]
except subprocess.CalledProcessError:
except (subprocess.CalledProcessError, FileNotFoundError):
return None

def check_version(self) -> str:
Expand Down Expand Up @@ -101,17 +102,16 @@ def get_cpu_info() -> str:
def get_docker_platform() -> str:
try:
output = (
subprocess.check_output( # noqa: S602
"docker info --format '{{.OperatingSystem}}'", # noqa: S607
shell=True, # noqa: S607
subprocess.check_output(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subprocess call without shell validation

The subprocess.check_output() call on line 105 uses a hardcoded command list, which is safe. However, ensure this pattern is consistently applied throughout the codebase.

Code Review Run #391d30


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

["docker", "info", "--format", "{{.OperatingSystem}}"]
)
.decode()
.strip()
)
if "Docker Desktop" in output:
return f"Docker Platform: {output} ({platform.system()})"
return f"Docker Platform: {output}"
except subprocess.CalledProcessError:
except (subprocess.CalledProcessError, FileNotFoundError):
return "Docker Platform: ❌ Not Detected"


Expand Down
Loading