Skip to content

Commit e7bf16a

Browse files
committed
fix(ui): allow graph schema through UI RPC
Fixes DeusData#1663 Signed-off-by: astandrik <[email protected]>
1 parent 641c71f commit e7bf16a

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎src/ui/http_server.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,8 @@ static bool rpc_is_allowed_for_ui(const char *body, size_t body_len) {
17561756
const char *name_text = yyjson_is_str(name) ? yyjson_get_str(name) : NULL;
17571757
bool allowed =
17581758
method_text && strcmp(method_text, "tools/call") == 0 && name_text &&
1759-
(strcmp(name_text, "list_projects") == 0 || strcmp(name_text, "get_code_snippet") == 0);
1759+
(strcmp(name_text, "list_projects") == 0 || strcmp(name_text, "get_code_snippet") == 0 ||
1760+
strcmp(name_text, "get_graph_schema") == 0);
17601761
yyjson_doc_free(document);
17611762
return allowed;
17621763
}

‎tests/test_httpd.c‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,22 +1169,31 @@ TEST(ui_server_mutations_require_json_content_type) {
11691169
TEST(ui_server_rpc_allows_only_ui_read_tools) {
11701170
th_server_t ts;
11711171
ASSERT_EQ(th_server_start(&ts), 0);
1172-
const char *body = "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\","
1173-
"\"params\":{\"name\":\"list_projects\",\"arguments\":{}}}";
11741172
char req[1024];
1175-
snprintf(req, sizeof(req),
1176-
"POST /rpc HTTP/1.1\r\n"
1177-
"Content-Type: application/json\r\n"
1178-
"Content-Length: %d\r\n\r\n%s",
1179-
(int)strlen(body), body);
11801173
char resp[8192];
1181-
int n = th_http(cbm_http_server_port(ts.srv), req, resp, sizeof(resp));
1182-
ASSERT_GT(n, 0);
1183-
ASSERT_EQ(th_status(resp), 200);
1184-
ASSERT_NOT_NULL(strstr(resp, "\"jsonrpc\""));
1174+
int n;
1175+
1176+
static const char *allowed_tools[] = {"list_projects", "get_code_snippet", "get_graph_schema"};
1177+
for (size_t i = 0; i < sizeof(allowed_tools) / sizeof(allowed_tools[0]); i++) {
1178+
char allowed_body[512];
1179+
snprintf(allowed_body, sizeof(allowed_body),
1180+
"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\","
1181+
"\"params\":{\"name\":\"%s\",\"arguments\":{}}}",
1182+
allowed_tools[i]);
1183+
snprintf(req, sizeof(req),
1184+
"POST /rpc HTTP/1.1\r\n"
1185+
"Content-Type: application/json\r\n"
1186+
"Content-Length: %zu\r\n\r\n%s",
1187+
strlen(allowed_body), allowed_body);
1188+
n = th_http(cbm_http_server_port(ts.srv), req, resp, sizeof(resp));
1189+
ASSERT_GT(n, 0);
1190+
ASSERT_EQ(th_status(resp), 200);
1191+
ASSERT_NOT_NULL(strstr(resp, "\"jsonrpc\""));
1192+
ASSERT_NULL(strstr(resp, "UI RPC method is not allowed"));
1193+
}
11851194

1186-
static const char *blocked_tools[] = {"delete_project", "manage_adr", "ingest_traces",
1187-
"index_repository"};
1195+
static const char *blocked_tools[] = {"search_graph", "delete_project", "manage_adr",
1196+
"ingest_traces", "index_repository"};
11881197
for (size_t i = 0; i < sizeof(blocked_tools) / sizeof(blocked_tools[0]); i++) {
11891198
char blocked_body[512];
11901199
snprintf(blocked_body, sizeof(blocked_body),

0 commit comments

Comments
 (0)