mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
fix: is_public_blocked_tool crashes on a truthy non-string tool name (#1620)
* fix: is_public_blocked_tool crashes on a truthy non-string tool name * fix: is_public_blocked_tool fails closed (blocks) on a malformed non-string tool name
This commit is contained in:
+10
-2
@@ -48,9 +48,17 @@ NON_ADMIN_BLOCKED_TOOLS = {
|
||||
|
||||
|
||||
def is_public_blocked_tool(tool_name: Optional[str]) -> bool:
|
||||
"""Return True when a non-admin/public user must not execute this tool."""
|
||||
if not tool_name:
|
||||
"""Return True when a non-admin/public user must not execute this tool.
|
||||
|
||||
This is a security gate, so it fails CLOSED: a malformed non-string tool
|
||||
name can't be matched against the blocklist or the ``mcp__`` namespace, so
|
||||
it is treated as blocked rather than silently allowed through. ``None`` /
|
||||
empty string means there is no tool to gate.
|
||||
"""
|
||||
if tool_name is None or tool_name == "":
|
||||
return False
|
||||
if not isinstance(tool_name, str):
|
||||
return True
|
||||
return tool_name in NON_ADMIN_BLOCKED_TOOLS or tool_name.startswith("mcp__")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user