mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 20:16:48 +00:00
fix(pat): close message replay to restricted tokens, filter builtin tools, reject non-object bodies
Message tail and the ASGI reconnect stream cannot tie a message to an allowlist, so any token with a resource filter is refused there. The tools listing now applies the allowlist to default and builtin rows as well. Token creation answers 400 instead of 500 for a JSON body that is not an object.
This commit is contained in:
1 parent
17d66c061d
commit
934ae1afb3
8 files changed
+45
-7
No files matched your search
@@ -266,9 +266,6 @@ class GetTools(Resource):
|
||||
shaped = _shape_tool(row, ownership="team", force_strip_secret=True)
|
||||
shaped["team_access"] = team_shared.get(str(row["id"]))
|
||||
user_tools.append(shaped)
|
||||
# A resource-restricted token sees only its allowed tools; the
|
||||
# default and builtin rows appended below belong to no user.
|
||||
user_tools = filter_listing(request, "tools", user_tools)
|
||||
|
||||
# ``scheduler`` is dual-registered (default chat tool + agent-
|
||||
# selectable builtin) and resolves to the same synthetic uuid5 id.
|
||||
@@ -298,6 +295,9 @@ class GetTools(Resource):
|
||||
builtin_copy.get("name") in WORKFLOW_ONLY_BUILTINS
|
||||
)
|
||||
user_tools.append(builtin_copy)
|
||||
# A resource-restricted token sees only its allowed tools. Default
|
||||
# and builtin rows have ids too, so they follow the same allowlist.
|
||||
user_tools = filter_listing(request, "tools", user_tools)
|
||||
except Exception as err:
|
||||
current_app.logger.error(f"Error getting user tools: {err}", exc_info=True)
|
||||
return make_response(jsonify({"success": False}), 400)
|
||||
|
||||
Reference in new issue
Block a user