Repository navigation
feat(connections): connect through a Unix socket, locally or over the SSH tunnel (#1002) - #1250
Conversation
| * @param params - Connection parameters (any object carrying the three fields) | ||
| * @returns The trimmed socket path, or null when none applies | ||
| */ | ||
| /** |
There was a problem hiding this comment.
WARNING: hasUnixSockets was inserted between the effectiveLocalSocketPath JSDoc and its function
The doc block above (lines 181-188, "The local Unix socket path in effect for a connection...") now sits directly before the hasUnixSockets JSDoc, so effectiveLocalSocketPath (below hasUnixSockets) has no documentation and an orphaned doc block precedes an unrelated function. Move hasUnixSockets (with its JSDoc) above the effectiveLocalSocketPath doc block, or below effectiveLocalSocketPath.
|
|
||
| const socketPath = effectiveLocalSocketPath(params); | ||
| if (socketPath) { | ||
| return `${socketPath}/${params.database}`; |
There was a problem hiding this comment.
SUGGESTION: Socket display string reads as a filesystem path
${socketPath}/${params.database} produces e.g. /tmp/mysql.sock/mydb, which looks like a path inside the socket file. connectionSubtitle uses socketPath · db for the same case. Consider a distinct, unambiguous format (e.g. socket:/tmp/mysql.sock/mydb) so the label is not mistaken for a path and stays consistent with the pool key's socket:<path> convention.
| // `mysql://root@localhost/db?socket=/tmp/mysql.sock`: the socket replaces | ||
| // host:port (the host is kept so the form can switch back). | ||
| const unix_socket_path = | ||
| resolved.id === 'mysql' ? url.searchParams.get('socket')?.trim() || undefined : undefined; |
There was a problem hiding this comment.
SUGGESTION: ?socket= import is hardcoded to the driver id mysql
resolved.id === 'mysql' ignores ?socket= for any other MySQL-dialect or unix_socket-capable driver that owns the mysql/mariadb scheme (e.g. a MariaDB plugin), even though the rest of the PR gates the feature on the unix_socket capability. .rules/plugins.md asks for capabilities over driver ids; consider checking the driver's unix_socket capability / sql_dialect === 'mysql' here (the modal already does this at importingMysql).
| connection_uri_in_keychain: false, | ||
| // `?socket=` switches the form to the socket endpoint; a string | ||
| // without it goes back to host and port. | ||
| unix_socket_path: parsed.unix_socket_path, |
There was a problem hiding this comment.
WARNING: Imported ?socket= can be saved while the socket UI is hidden (Windows)
On Windows hasUnixSockets() is false, so canUseSocket/socketMode are false (unless SSH is on) and the host/port inputs are shown, but this line still writes the imported unix_socket_path into formData. It is then persisted and sent to the backend, where local_unix_socket_path() is set and build_mysql_options returns "Unix socket connections are not supported on Windows" - with no visible field the user can edit to fix it, and host/port are silently ignored. Drop the parsed socket when !hasUnixSockets() (and no SSH), or clear unix_socket_path when the socket endpoint is not selectable.
| "socketPathForwardActive": "The SSH server connects to this socket instead of Host and Port. A database on a socket cannot negotiate TLS, so it is turned off; the SSH tunnel still encrypts the whole path.", | ||
| "socketPathNotAbsolute": "Enter an absolute path, as it appears on the machine that connects to the socket.", | ||
| "socketPathDirectory": "Point at the socket file itself, not the directory holding it.", | ||
| "socketPathTunnel": "Not used while a Kubernetes tunnel is enabled.", |
There was a problem hiding this comment.
SUGGESTION: newConnection.socketPathTunnel is never used
The key is added to all 11 locales but nothing in src/ references it (the endpoint selector is hidden while K8s is enabled, so the message is never rendered). Either render it where the socket is ignored or drop the key from every locale.
Code Review SummaryStatus: No New Issues Found | Recommendation: Merge Files Reviewed (incremental changes since the last review)
Notes:
No code was run (read-only mode). Previous Review Summaries (14 snapshots, latest commit 8ecc080)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 8ecc080)Status: No New Issues Found | Recommendation: Merge Files Reviewed (incremental changes since the last review)
Notes:
No code was run (read-only mode). Previous review (commit 5ed11f7)Status: No New Issues Found | Recommendation: Merge Files Reviewed (incremental changes since the last review)
Notes:
No code was run (read-only mode). Previous review (commit 2074474)Status: No New Issues Found | Recommendation: Merge Files Reviewed (1 file in the incremental diff)
Notes: The incremental diff since the last review adds only
Earlier inline comments on this PR (from previous commits) remain in the review threads; they are not re-listed here. No code was run (read-only mode). Previous review (commit 92b9ddb)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files in the incremental diff)
Notes: The incremental diff since the last review adds
No code was run (read-only mode). Previous review (commit 1c55fa8)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files in the incremental diff)
Notes: The branch was rebased onto a newer
No code was run (read-only mode). Previous review (commit 129bd1d)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files in the incremental diff)
Notes: The incremental diff since Previous review (commit 989c8bd)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files in the incremental diff)
Notes: The incremental diff since Previous review (commit 402d058)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files in the incremental diff)
Notes: The incremental diff since Previous review (commit 2870307)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files in the incremental diff)
Notes: The incremental diff since Previous review (commit 2e78315)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (35 files)
Notes: The only commit since the last review ( Fix these issues in Kilo Cloud Previous review (commit 4b92aed)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (35 files)
Notes: The PR was rebased onto a newer main, so this is a full review of the current diff. The earlier JSDoc, Fix these issues in Kilo Cloud Previous review (commit 8aadc33)Status: No Issues Found | Recommendation: Merge Files Reviewed (16 files in this increment)
Notes: The latest commit resolves all five earlier findings, and the changed code raises no new issues. No code was run (read-only mode). Previous review (commit 96af7ee)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (1 file in this increment)
Notes: The latest commit only swaps Fix these issues in Kilo Cloud Previous review (commit 5f47447)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (33 files)
Notes: Rust changes were reviewed by reading only; no tests were run (read-only mode). SSH, K8s and SSM tunnels clear the socket path before the drivers see it, and the pool key and driver options use Reviewed by claude-sonnet-5.5 · Input: 256 · Output: 1.2K · Cached: 290.8K Review guidance: REVIEW.md from base branch |
debba
left a comment
There was a problem hiding this comment.
Thanks for porting #492 and bringing it up to date, and for crediting it properly! params_through_tunnel is the part I like best: it clears unix_socket_path so the driver can't bypass the tunnel's local port, and it turns DB TLS off only when the forward goes to a socket. Keeping socket and TCP endpoints apart in both the tunnel and the pool keys, with tests, is exactly right.
A few things need fixing:
Plugin contract. The new unix_socket capability isn't in plugins/manifest.schema.json or PLUGIN_GUIDE.md. The schema's capabilities object has additionalProperties: false, so a plugin that opts in through its manifest, as the description says, would fail schema validation. Please also document what plugin drivers receive in unix_socket_path (see .rules/plugins.md).
A hidden socket path still gets sent. socketMode is canUseSocket && unix_socket_path !== undefined, but the test and save builders spread the whole formData. On Windows: enable SSH, pick Socket Path, then disable SSH. The field disappears and Host/Port come back, but the path is still saved, and the backend refuses it with "Unix socket connections are not supported on Windows". validateConnectionParams also stops asking for a host. On Linux, doing the same with a driver that lacks the capability leaves a stale path that skips the DB-scope proxy and changes the pool key. Dropping unix_socket_path whenever !socketMode fixes it.
Rebase. #676 moved things around. resolve_connection_transport, resolve_ssh_params, resolve_ssm_params and resolve_k8s_params now live in src-tauri/src/application/tunnels.rs, so ssh_forward_destination, params_through_tunnel and the socket short-circuit go there, with their tests in application/tunnels_tests.rs. Other changes:
- The two
expand_k8s_connection_paramshunks can be dropped, because main's version already delegates toresolve_expanded_connection_params. new_with_tcp_overrideis nownew_with_askpass(...), soSshForwardDestinationhas to go through that signature.- Main's
resolve_ssh_paramshas nois_alivecheck, so the tunnel reuse hunk doesn't apply as is. - The frontend moves to
packages/web-ui/src.NewConnectionModalchanged quite a bit, so that one needs a manual merge.
The good news is that once the logic is in application/, the web RPC gets socket support for free.
Smaller things:
- SSM isn't taken into account on the frontend: with SSM on, the UI says the socket is used, but the backend clears it.
- Postgres directory paths work locally but not over SSH, because streamlocal needs the socket file.
unixSocketPathIssueonly warns on a trailing/, so/var/run/postgresqlpasses the check and then fails at the SSH channel. - The description says the Windows tests run in CI, but unit tests only run on ubuntu-24.04, so the
#[cfg(windows)]test never runs. connections.tshas acapabilities == null && (driver === 'mysql' || driver === 'postgres')fallback, which goes against rule 2 in.rules/plugins.md.- Over an SSH-forwarded socket,
ssl_modeis forced to disable and then the cleartext auth check refuses the connection, while a local socket is exempt. Rare, but inconsistent. - In
tabularis web,hasUnixSockets()reads the browser'snavigator.platform, but the server is the one dialing the socket.
8aadc33 to
daa3724
Compare
|
Addressed all feedback and rebased on latest
|
| const supportsUnixSocket = activeDriver?.capabilities?.unix_socket === true && hasUnixSockets(); | ||
| const tunnelEnabled = !!formData.ssh_enabled || !!formData.k8s_enabled; | ||
| const socketPathSet = !!formData.unix_socket_path?.trim(); | ||
| const canUseSocket = |
There was a problem hiding this comment.
WARNING: Socket UI stays active while AWS SSM is enabled, but the backend discards the socket
tunnelEnabled (line 651) and canUseSocket only account for SSH and K8s, not ssm_enabled. With SSM on, the endpoint selector and Socket Path field stay visible, usesLocalSocket is true (so the hint says "The connection uses this socket instead of Host and Port"), and socketMode keeps unix_socket_path in the saved/tested params. resolve_ssm_params then sets unix_socket_path = None and forwards to host:port, which is hidden in socket mode and so unset (it falls back to localhost:DEFAULT_REMOTE_PORT). The user is told one thing and the connection does something else. Treat SSM like K8s here: exclude ssm_enabled from canUseSocket and include it in tunnelEnabled, so the path is dropped by the socketMode guard when SSM is on.
|
Addressed the SSM tunnel edge case flagged by @kilo-code-bot and @debba:
|
|
@debba All requested points have been fully addressed:
Ready for your final review and approval! |
debba
left a comment
There was a problem hiding this comment.
Thanks for working through the rebase and the SSM case. The socket transport now sits in application/tunnels.rs, the plugin schemas and guide include unix_socket, and Test/Save omit the path when socket mode is unavailable. The SSM selector change is in place too.
One part of the hidden-path fix is still missing: loadDatabases in packages/web-ui/src/components/modals/NewConnectionModal.tsx spreads formData and overrides without applying the socket-mode check used by Test/Save.
I reproduced it with the real modal using the existing test harness: an edited connection has unix_socket_path: '/tmp/old.sock' and a driver without the local socket capability. The UI shows Host/Port and no socket selector, but clicking Load databases still sends /tmp/old.sock to list_databases. My added check expecting the path to be omitted fails. This also leaves the Windows flow from my previous review broken for database discovery, and on Unix the backend can dial the hidden socket instead of the host shown in the form.
Please sanitize the discovery parameters too, including the edit-time overrides path, and add a regression test that captures the list_databases request while the socket field is hidden. Keep the valid SSH-forwarded socket case working.
The existing 244 targeted frontend tests, typecheck, build, ESLint, Prettier, frontend boundary/inventory checks and the desktop-free cargo check pass. The failure above is an uncovered case, not a CI failure. Requesting changes until it is fixed.
|
Addressed the discovery sanitization feedback:
|
debba
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround on discovery. loadDatabases now works out socket eligibility from both the form and the edit-time overrides, and the two new tests are the right ones. I put the previous version of the modal back and both "omits hidden unix_socket_path" tests failed, then passed again with your change. The SSH-forwarded case also still sends the path, as it should.
There's one regression in the new code that I need fixed before merging. In loadDatabases, the path is picked with overrides?.unix_socket_path !== undefined ? overrides.unix_socket_path : formData.unix_socket_path. The connection string import calls loadDatabases(parsedFields) with unix_socket_path: undefined on purpose when the string has no ?socket=, because that's how it switches the form back to host and port. With the new check, that explicit undefined falls back to the old formData value.
I reproduced it in the modal test harness: edit a MySQL connection with SSH on and /var/run/mysqld/mysqld.sock, then paste mysql://root:pw@db2.example.com:3306/shop. The form shows db2.example.com, but list_databases still gets unix_socket_path: '/var/run/mysqld/mysqld.sock', so discovery goes to the old socket. Before this commit the plain spread let the undefined win and nothing was sent. The same applies to a local socket on Linux and macOS, since the built-in MySQL driver has the unix_socket capability.
The simplest fix is to build the merged object first ({...formData, ...overrides}) and work out eligibility and the path from that, so an explicit key in overrides keeps winning like it did before. Checking 'unix_socket_path' in overrides also works. Please add a regression test for the import case: start in socket mode, paste a string without ?socket=, and assert that the captured list_databases params have no unix_socket_path.
A few smaller things while you're in there:
- The eligibility rules are now copied in three places in
NewConnectionModal.tsx:canUseSocket,loadDatabasesandsocketFieldAvailablein the import handler. A small pure helper inutils/connections.tstaking the capabilities and the SSH/K8s/SSM flags, with its own unit tests, would keep them from drifting. This bug is a good example of why. - In
loadDatabases,unix_socket_pathis set toundefined, deleted fromlistParamsBase, and then deleted again fromlistParams, which can't contain it anymore. One of those is enough. list_databasesis typed asstring[]in the API contract, so theArray.isArrayfallback isn't needed. If it ever did trigger, the picker would quietly come up empty instead of showing an error. I'd drop it.
Everything else checks out on my side: the targeted frontend tests (247), build, ESLint, Prettier, the tunnels and pool_manager Rust tests and the desktop-free cargo check all pass, and CI is green. Once the import case is fixed and covered, I'll do a manual pass and we can merge.
|
Thanks for catching the import regression! Addressed all points in commit 129bd1d:
All 187 targeted tests, TypeScript typecheck, Vite build, Prettier, ESLint, web boundaries, and API inventory checks pass cleanly. |
129bd1d to
1c55fa8
Compare
|
@debba Rebased onto current |
debba
left a comment
There was a problem hiding this comment.
Thanks for fixing the import reset and pulling socket eligibility into isSocketEligible. I ran the new import regression against the previous modal: it fails with the stale /var/run/mysqld/mysqld.sock, then passes with this head. All 267 targeted frontend tests, 98 existing pool tests, 27 SSH tests and 11 application tunnel tests pass.
The real socket check turned up a blocker in the PostgreSQL path. I started a separate PostgreSQL 16 fixture and pointed unix_socket_path at its .s.PGSQL.5432 file. get_postgres_pool_with_id builds the pool, but pool.get() fails with Backend(Error { kind: Tls, cause: Some(InvalidDnsNameError) }). The fixture is healthy and its socket accepts connections; a temporary test that reads its three seeded rows fails at pool checkout.
build_postgres_configurations correctly sets host_path and disables SSL. The problem is that tokio-postgres still calls make_tls_connect(hostname.unwrap_or("")) before entering the SSL-disabled connection path. A Unix socket has no hostname, and MakeRustlsConnect rejects the empty name. Disabling SSL in the config alone therefore doesn't make this connector usable over a local socket.
Please make the PostgreSQL connector handle a local socket without hostname validation while preserving the existing TCP TLS checks, and add a live socket regression. The same connector is used by Test Connection and the startup-script preflight, so please cover those paths too. The import fix is good; I'm requesting changes for the PostgreSQL socket failure.
2074474 to
5ed11f7
Compare
|
@debba Addressed the PostgreSQL Unix socket TLS blocker and rebased cleanly onto latest
All unit and integration checks, TypeScript typecheck, and Vitest test suites (246/246) pass cleanly. |
NewtTheWolf
left a comment
There was a problem hiding this comment.
Thanks for fixing the empty-hostname TLS construction. On 8ecc0806, PostgresTlsConnector supplies the local fallback only for an empty hostname; nonempty TCP hostnames still go through the existing verifier. The pool, Test Connection and startup-script paths all use that connector.
I ran the added live regression against an isolated PostgreSQL 17.9 server through its actual .s.PGSQL.5432 Unix socket. Test Connection succeeded, pool checkout returned the expected query result, and the startup-script preflight also succeeded. That test ran and passed; it was not an ignored test silently skipped.
The 318 affected frontend tests, typecheck, lint, production build and desktop-free cargo check pass. The full Rust library suite passes serially with 2,546 passed and 19 ignored. I have not exercised a remote SSH socket or the modal in the native app during this pass.
The reported PostgreSQL blocker is resolved on my side. Approved, leaving Debba's outstanding review for Debba to clear.
debba
left a comment
There was a problem hiding this comment.
Thanks for fixing the empty-hostname TLS construction and using the connector consistently in the pool, Test Connection and startup-script paths. Nonempty TCP hostnames still go through the existing connector unchanged.
I ran the 318 affected frontend tests, typecheck and all 20 TLS connector tests on this head. I also ran the added live regression against an isolated PostgreSQL 16 server through its actual Unix socket: Test Connection, pool checkout/query and startup-script preflight all succeed. The TLS failure from my previous review is resolved.
One integration blocker remains. A local merge with current main conflicts in src-tauri/src/application/tunnels.rs, src-tauri/src/application/tunnels_tests.rs and src-tauri/src/ssh_tunnel.rs. Please rebase those transport changes onto main, preserving socket forwarding and the TLS correction, then rerun the tunnel tests and live socket regression on the integrated revision.
Requesting changes for the rebase. I have not repeated the remote SSH socket flow in the desktop app.
…TabularisDB#1002) - Rebase on upstream/main after application layer tunnel migration (TabularisDB#676) - Wire SshForwardDestination and params_through_tunnel into application/tunnels.rs - Add unix_socket capability to manifest.schema.json, tabularium-extensions, and PLUGIN_GUIDE.md - Clear unix_socket_path when not in socketMode in NewConnectionModal - Clear unix_socket_path in K8s and SSM tunnels
…alidation AWS SSM tunnels, like Kubernetes port-forwards, only support TCP forwards. When ssm_enabled is true, resolve_ssm_params clears unix_socket_path. Ensure the web UI is fully consistent with backend behavior: - Include ssm_enabled in tunnelEnabled and exclude it from canUseSocket in NewConnectionModal so the socket endpoint selector and active hint are hidden and socketMode is disabled. - Sanitize imported ?socket= connection strings by checking !ssm_enabled in socketFieldAvailable. - Treat ssm_enabled as overriding local socket in effectiveLocalSocketPath and require a host in validateConnectionParams. - Add unit test coverage for SSM tunnel socket exclusion in both connections.test.ts and NewConnectionModal.test.tsx.
…tion string import - Merge formData and overrides in loadDatabases so explicit undefined overrides clear stale unix_socket_path - Extract isSocketEligible pure helper in utils/connections.ts with dedicated unit tests - Remove redundant delete and drop unused Array.isArray fallback on list_databases - Add regression test for pasting connection string without ?socket= over socket form
…onnection, and startup scripts
8ecc080 to
82509c4
Compare
|
@debba Rebased onto |
There was a problem hiding this comment.
The Unix socket/TLS correction is preserved after integration with current main, including provider metadata bindings in the connection modal and all 13 locales.
On 2595d1e, the CI trigger-editor failure is addressed by explicitly awaiting the mocked Monaco onMount before editing/saving its buffer. Delaying that callback reproduced the original assertion failure; the corrected synchronization passes. The committed test contains no artificial delay.
Final local validation: complete frontend suite (606 files, 9,610 tests), 2,703 desktop-free Rust library tests (18 ignored), lint, production build/typecheck, PostgreSQL 16 live socket regression (Test Connection, pool query and startup-script preflight), and all 4 integrated Chromium environment/provider/Vim checks pass. Generated guest artifacts remain synchronized. Remote SSH-to-socket behavior was not repeated in the native desktop UI.
Merge remains conditional on green CI for this head.
Closes #1002. Based on the Unix socket design in #492 (@debba); supersedes #1246.
Adds a capability-gated Unix socket endpoint in place of Host and Port. MySQL/MariaDB dial the socket directly; PostgreSQL accepts a socket filename (including its port) or socket directory. Local socket connections disable database TLS, bypass database-scope TCP proxies and reject AWS IAM authentication. The PostgreSQL TLS connector handles sockets without empty-hostname validation while retaining the existing validation for TCP connections.
SSH forwards to the socket on the SSH server through system OpenSSH or russh streamlocal forwarding, including a proxied bastion. K8s and AWS SSM remain TCP-only and clear the socket path. Windows hides/rejects local Unix sockets but can reach a remote socket through SSH.
Plugin drivers opt in with the
unix_socketcapability; unsupported drivers do not get the endpoint selector. The connection types, capability schemas and plugin guide are updated together. Labels and hints cover all 13 locales. Connection labels and pool keys distinguish socket endpoints, and MySQL URLs can import?socket=.The branch is integrated with current main, preserving provider metadata/credential bindings in the connection modal. A CI race in the existing trigger-editor test is corrected by waiting for its mocked Monaco
onMountbefore editing/saving its buffer. Delaying that callback reproduced the original failure; the corrected synchronization passes without an artificial delay in the committed test.Validation on 2595d1e:
Remote SSH-to-socket behavior was not repeated in the native desktop UI. Merge remains conditional on green CI for this head.