Skip to content
Merged
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
6 changes: 3 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ async def enable_cors(request, response):


async def start_vue_dev_server():
await asyncio.create_subprocess_shell(
"npm run dev", stdout=sys.stdout, stderr=sys.stderr, cwd=MAGMA_PATH
proc = await asyncio.create_subprocess_exec(
"npm", "run", "dev", stdout=sys.stdout, stderr=sys.stderr, cwd=MAGMA_PATH
)
logging.info("VueJS development server is live.")
logging.info("VueJS development server started (PID %s).", proc.pid)
Comment on lines +159 to +162


def _get_parser():
Expand Down
21 changes: 21 additions & 0 deletions tests/security/test_subprocess_exec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ast
from pathlib import Path


SERVER_PY = Path(__file__).resolve().parents[2] / 'server.py'


def test_no_create_subprocess_shell_in_start_vue():
"""Verify create_subprocess_shell is not used in start_vue_dev_server."""
content = SERVER_PY.read_text(encoding='utf-8')
tree = ast.parse(content, filename=str(SERVER_PY))
func_node = None
for node in ast.walk(tree):
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name == 'start_vue_dev_server':
func_node = node
break
assert func_node is not None, "start_vue_dev_server function not found in server.py"
func_content = ast.get_source_segment(content, func_node)
assert func_content is not None, "Could not extract source for start_vue_dev_server"
assert 'create_subprocess_shell' not in func_content
assert 'create_subprocess_exec' in func_content
Comment on lines +18 to +21
Comment on lines +18 to +21
Comment on lines +18 to +21
Comment on lines +20 to +21
Comment on lines +18 to +21
Loading