fix(mongodb): guard aggregate execution paths

This commit is contained in:
徐文彬 committed 2026-05-28 21:29:08 +08:00
1 parent c56bcb8e2d
commit 5ea146e08e
19 files changed
+166 -26

No files matched your search

+1
View File
@@ -143,6 +143,7 @@ mod tests {
ssh_key_passphrase: String::new(),
ssh_expose_lan: false,
ssh_connect_timeout_secs: dbx_core::models::connection::default_ssh_connect_timeout_secs(),
connect_timeout_secs: dbx_core::models::connection::default_connect_timeout_secs(),
query_timeout_secs: dbx_core::models::connection::default_query_timeout_secs(),
proxy_enabled: false,
proxy_type: ProxyType::Socks5,
+8
View File
@@ -22,6 +22,8 @@ struct ExecuteQueryRequest {
database: Option<String>,
sql: String,
schema: Option<String>,
allow_writes: Option<bool>,
allow_dangerous: Option<bool>,
}
#[derive(Deserialize)]
@@ -56,6 +58,7 @@ struct MongoAggregateDocumentsRequest {
database: Option<String>,
collection: String,
pipeline_json: String,
max_rows: Option<usize>,
}
#[derive(Deserialize)]
@@ -98,6 +101,8 @@ pub struct McpExecuteQueryEvent {
pub connection_id: String,
pub database: String,
pub sql: String,
pub allow_writes: bool,
pub allow_dangerous: bool,
}
pub fn start(app_handle: AppHandle, state: Arc<AppState>) {
@@ -282,6 +287,8 @@ async fn handle_execute_query(app: &AppHandle, state: &Arc<AppState>, body: &str
connection_id: config.id.clone(),
database: req.database.unwrap_or_else(|| config.database.clone().unwrap_or_default()),
sql: req.sql,
allow_writes: req.allow_writes.unwrap_or(false),
allow_dangerous: req.allow_dangerous.unwrap_or(false),
};
let _ = app.emit("mcp-execute-query", &event);
respond(stream, "200 OK", "ok").await;
@@ -398,6 +405,7 @@ async fn handle_mongo_aggregate_documents_data(state: &Arc<AppState>, body: &str
&database,
&req.collection,
&req.pipeline_json,
req.max_rows,
)
.await
{
+10 -2
View File
@@ -52,9 +52,17 @@ pub async fn mongo_aggregate_documents(
database: String,
collection: String,
pipeline_json: String,
max_rows: Option<usize>,
) -> Result<MongoDocumentResult, String> {
dbx_core::mongo_ops::mongo_aggregate_documents_core(&state, &connection_id, &database, &collection, &pipeline_json)
.await
dbx_core::mongo_ops::mongo_aggregate_documents_core(
&state,
&connection_id,
&database,
&collection,
&pipeline_json,
max_rows,
)
.await
}
#[tauri::command]