feat(mongodb): support db.getSiblingDB()
This commit is contained in:
1 parent
b44e1080a8
commit
f1e0f54a2b
9 files changed
+262
-8
No files matched your search
@@ -1638,6 +1638,9 @@ impl DbxBackend for WebBackend {
|
||||
self.ensure_connected(connection).await?;
|
||||
let connection_id = &connection.id;
|
||||
match command {
|
||||
MongoCommand::InDatabase { database, command } => {
|
||||
Box::pin(self.execute_mongo_command(connection, database, command)).await
|
||||
}
|
||||
MongoCommand::Version => {
|
||||
let version: String = self
|
||||
.request(
|
||||
|
||||
@@ -2202,11 +2202,13 @@ fn validate_mongo_command_with_groups(
|
||||
}
|
||||
let effective_policy = effective_policy_for_database_with_groups(policy, group_ids, connection, database);
|
||||
let permissions = mcp_permissions(connection, &effective_policy);
|
||||
// getSiblingDB() targets another database for this command only; judge that one.
|
||||
let target_database = command.target_database().unwrap_or(database);
|
||||
let production_database = match &command {
|
||||
MongoCommand::Aggregate { pipeline, .. } => {
|
||||
mongo_pipeline_targets_production_database(connection, database, pipeline)
|
||||
mongo_pipeline_targets_production_database(connection, target_database, pipeline)
|
||||
}
|
||||
_ => is_production_database(connection, database),
|
||||
_ => is_production_database(connection, target_database),
|
||||
};
|
||||
if let Err(error) =
|
||||
mongo::validate_safety(&command, permissions.allow_writes, permissions.allow_dangerous, production_database)
|
||||
|
||||
Reference in new issue
Block a user