mirror of
https://github.com/usestrix/strix.git
synced 2026-08-28 05:25:00 +00:00
guardrails: block destructive commands in exec_command (fixes #952)
This commit is contained in:
parent
a9deb84260
commit
edf5b8d13f
1 changed files with 5 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ from agents.tool import CustomTool, FunctionTool, Tool
|
|||
from pydantic import ValidationError
|
||||
|
||||
from strix.agents.prompt import render_system_prompt
|
||||
from strix.agents.guardrails import check_destructive
|
||||
from strix.config import load_settings
|
||||
from strix.tools.agents_graph.tools import (
|
||||
agent_finish,
|
||||
|
|
@ -281,6 +282,10 @@ def _wrap_exec_command(tool: FunctionTool) -> FunctionTool:
|
|||
parsed = json.loads(raw_input)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
parsed = None
|
||||
if isinstance(parsed, dict) and "cmd" in parsed:
|
||||
reason = check_destructive(parsed.get("cmd", ""))
|
||||
if reason:
|
||||
return f"[guardrail] blocked destructive command: {reason}"
|
||||
if isinstance(parsed, dict):
|
||||
if "shell" not in parsed:
|
||||
parsed["shell"] = "bash"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue