Skip to content

Commit 4655bf7

Browse files
committed
fix(db): drop dead host/port args from ssh_db
creds() in the ssh_db dispatcher forwarded host and port to all four db handlers, and the ssh_db inputSchema declared them -- but no db-tools handler or command builder reads either. buildMongoConnectionUri is the only place with host/port parameters and its sole caller never passes them, so every db op always hits the local socket. A caller passing host/port for a remote DB silently got the local one. Remove host/port from creds() and from the ssh_db inputSchema, and drop the host/port assertions from the dispatcher test (user/password forwarding still covered). Not wired through -- that is a feature, out of scope. Re-add only alongside a handler that honors them.
1 parent 8e5120d commit 4655bf7

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/dispatchers/ssh-db.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ const REQUIRED = {
1919
};
2020

2121
// Args common to every db handler: connection-target credentials.
22+
// No host/port: every db-tools handler hits the local socket -- forwarding
23+
// them was dead + misleading (a caller's remote host/port was silently
24+
// ignored). Re-add only alongside a handler that actually honors them.
2225
function creds(a) {
2326
return {
2427
server: a.server,
2528
db_type: a.db_type,
2629
database: a.database,
2730
user: a.user,
2831
password: a.password,
29-
host: a.host,
30-
port: a.port,
3132
format: a.format,
3233
};
3334
}

src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,6 @@ registerToolConditional('ssh_db', {
683683
gzip: z.boolean().optional().describe('Gzip the dump (action: dump)'),
684684
user: z.string().optional().describe('Database user'),
685685
password: z.string().optional().describe('Database password'),
686-
host: z.string().optional().describe('Database host'),
687-
port: z.number().optional().describe('Database port'),
688686
preview: z.boolean().optional().describe('Show the plan without importing (action: import)'),
689687
format: FORMAT,
690688
},

tests/test-dispatcher-db.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,12 @@ await test('db credential args are forwarded', async () => {
8282
deps: DEPS, handlers: { query },
8383
args: {
8484
server: 's', action: 'query', database: 'app', query: 'SELECT 1', db_type: 'mysql',
85-
user: 'u', password: 'p', host: 'h', port: 5432,
85+
user: 'u', password: 'p',
8686
},
8787
});
8888
const fwd = query.calls[0].args;
8989
assert.strictEqual(fwd.user, 'u');
9090
assert.strictEqual(fwd.password, 'p');
91-
assert.strictEqual(fwd.host, 'h');
92-
assert.strictEqual(fwd.port, 5432);
9391
});
9492

9593
await test('query missing query -> structured fail, handler not called', async () => {

0 commit comments

Comments
 (0)