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
18 changes: 15 additions & 3 deletions hermes_cli/mcp_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,24 @@ def _install_root() -> Path:
def _run_bootstrap(cwd: Path, commands: List[str]) -> None:
"""Execute bootstrap commands in *cwd*. Raise CatalogError on first failure.

Each command runs through the shell (so `&&` etc. work). The output is
streamed to the user's terminal for visibility.
Each command is split via ``shlex`` and run without ``shell=True`` to
prevent injection from untrusted YAML catalog entries. Shell operators
(``&&``, ``||``, ``|``) are **not** supported — use separate command
entries instead.

Raises ``CatalogError`` on non-zero exit or malformed commands.
"""
import shlex

for cmd in commands:
print(color(f" $ {cmd}", Colors.DIM))
proc = subprocess.run(cmd, cwd=str(cwd), shell=True)
try:

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.

On Windows, an npm-style bootstrap command now reaches subprocess as bare list argv. hermes_cli/_subprocess_compat.py:6-9 documents that this fails for npm's .cmd shim; please resolve the executable through the existing Windows-safe path before dropping shell=True.

args = shlex.split(cmd)
except ValueError as exc:
raise CatalogError(
f"bootstrap command has malformed shell syntax: {cmd!r} ({exc})"
) from exc
proc = subprocess.run(args, cwd=str(cwd), shell=False)
if proc.returncode != 0:
raise CatalogError(
f"bootstrap step failed (exit {proc.returncode}): {cmd}"
Expand Down