Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# See the LICENSE file for more information.
#
import argparse
import shlex
import subprocess
import sys
import os
Expand All @@ -15,7 +16,8 @@ def run_cmd(cmd: str, env: dict[str, str] | None = None) -> int:
if env is None:
env = os.environ.copy()
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, check=True, env=env)
# Use shell=False to avoid shell injection vulnerabilities
result = subprocess.run(shlex.split(cmd), shell=False, check=True, env=env)
return result.returncode


Expand Down
4 changes: 3 additions & 1 deletion packages/core_apps/default_app_cpp/tools/run_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import argparse
import platform
import shlex
import subprocess
import sys

Expand Down Expand Up @@ -52,7 +53,8 @@ def detect_arch() -> str:
def run_cmd(cmd: str) -> int:
"""Run a shell command."""
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, check=True)
# Use shell=False to avoid shell injection vulnerabilities
result = subprocess.run(shlex.split(cmd), shell=False, check=True)
return result.returncode


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
import argparse
import platform
import shlex
import subprocess
import sys
import os as os_module
Expand Down Expand Up @@ -53,7 +54,8 @@ def run_cmd(cmd: str, env: dict[str, str] | None = None) -> int:
if env is None:
env = os_module.environ.copy()
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, check=True, env=env)
# Use shell=False to avoid shell injection vulnerabilities
result = subprocess.run(shlex.split(cmd), shell=False, check=True, env=env)
return result.returncode


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

# npm install
print("Running npm install...")
result = subprocess.run(["npm", "install"], env=env, shell=True)
result = subprocess.run(["npm", "install"], env=env)
if result.returncode != 0:
print("npm install failed")
sys.exit(result.returncode)

# npm run build
print("Running npm run build...")
result = subprocess.run(["npm", "run", "build"], env=env, shell=True)
result = subprocess.run(["npm", "run", "build"], env=env)
if result.returncode != 0:
print("npm run build failed")
sys.exit(result.returncode)
Expand Down Expand Up @@ -51,5 +51,5 @@

# npm test
print("Running npm test...")
result = subprocess.run(["npm", "test"], env=env, shell=True)
result = subprocess.run(["npm", "test"], env=env)
sys.exit(result.returncode)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# See the LICENSE file for more information.
#
import argparse
import shlex
import subprocess
import sys
import os
Expand All @@ -15,7 +16,8 @@ def run_cmd(cmd: str, env: dict[str, str] | None = None) -> int:
if env is None:
env = os.environ.copy()
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, check=True, env=env)
# Use shell=False with shlex.split to avoid shell injection vulnerabilities
result = subprocess.run(shlex.split(cmd), shell=False, check=True, env=env)
return result.returncode


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# See the LICENSE file for more information.
#
import argparse
import shlex
import subprocess
import sys
import os
Expand All @@ -15,7 +16,8 @@ def run_cmd(cmd: str, env: dict[str, str] | None = None) -> int:
if env is None:
env = os.environ.copy()
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, check=True, env=env)
# Use shell=False with shlex.split to avoid shell injection vulnerabilities
result = subprocess.run(shlex.split(cmd), shell=False, check=True, env=env)
return result.returncode


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

# npm install
print("Running npm install...")
result = subprocess.run(["npm", "install"], env=env, shell=True)
result = subprocess.run(["npm", "install"], env=env)
if result.returncode != 0:
print("npm install failed")
sys.exit(result.returncode)

# npm run build
print("Running npm run build...")
result = subprocess.run(["npm", "run", "build"], env=env, shell=True)
result = subprocess.run(["npm", "run", "build"], env=env)
if result.returncode != 0:
print("npm run build failed")
sys.exit(result.returncode)
Expand All @@ -50,5 +50,5 @@

# npm test
print("Running npm test...")
result = subprocess.run(["npm", "test"], env=env, shell=True)
result = subprocess.run(["npm", "test"], env=env)
sys.exit(result.returncode)
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

# npm install
print("Running npm install...")
result = subprocess.run(["npm", "install"], env=env, shell=True)
result = subprocess.run(["npm", "install"], env=env)
if result.returncode != 0:
print("npm install failed")
sys.exit(result.returncode)

# npm run build
print("Running npm run build...")
result = subprocess.run(["npm", "run", "build"], env=env, shell=True)
result = subprocess.run(["npm", "run", "build"], env=env)
if result.returncode != 0:
print("npm run build failed")
sys.exit(result.returncode)
Expand Down
Loading