Enforce an explicit read-only tool allowlist
Remove every tool that is not explicitly approved for the private Buzz agent. This keeps future mutating tools closed by default instead of relying on a denylist that must be updated manually. Co-authored-by: fredamn76 <fredrik.fallman@gmail.com> Signed-off-by: fredamn76 <fredrik.fallman@gmail.com>
This commit is contained in:
@@ -31,19 +31,35 @@ def test_read_only_server_removes_all_mutating_tools():
|
||||
def search_recipes(query: str) -> list[str]:
|
||||
return [query]
|
||||
|
||||
def mutating_tool(value: str) -> str:
|
||||
@test_server.tool()
|
||||
def patch_recipe(value: str) -> str:
|
||||
return value
|
||||
|
||||
for name in server.WRITE_TOOL_NAMES:
|
||||
test_server.tool(name=name)(mutating_tool)
|
||||
@test_server.tool()
|
||||
def future_mutating_tool(value: str) -> str:
|
||||
return value
|
||||
|
||||
server._configure_read_only(test_server)
|
||||
server._configure_read_only(test_server, frozenset({"search_recipes"}))
|
||||
|
||||
tool_names = {tool.name for tool in asyncio.run(test_server.list_tools())}
|
||||
|
||||
assert tool_names == {"search_recipes"}
|
||||
|
||||
|
||||
def test_read_only_tool_allowlist_is_explicit():
|
||||
assert server.READ_ONLY_TOOL_NAMES == {
|
||||
"check_auth",
|
||||
"find_by_source_url",
|
||||
"get_recipe",
|
||||
"list_organizers",
|
||||
"resolve_foods",
|
||||
"scale_ingredients",
|
||||
"search_recipes",
|
||||
"suggest_recipes",
|
||||
"verify_recipe",
|
||||
}
|
||||
|
||||
|
||||
class TestUrlImportResponse:
|
||||
def test_slug_only_import_response_is_resolved_before_reporting(self, monkeypatch):
|
||||
recipe = {"slug": "lax-med-citron", "name": "Lax med citron", "recipeIngredient": []}
|
||||
|
||||
Reference in New Issue
Block a user