Skip to content

fix(connections): apply SSH profile edits and deletes to the connections that use them - #2872

Merged
datlechin merged 1 commit into
mainfrom
fix/credential-and-profile-defects
Sep 15, 2026
Merged

datlechin merged 1 commit into
mainfrom
fix/credential-and-profile-defects

Conversation

@datlechin

Copy link
Copy Markdown
Member

Foundation for reusable credential profiles (#2853), and the defects the investigation for it turned up in the same subsystem. No new feature here: this makes the profile and credential path correct so the credential profile itself can be built on it.

The defect that shaped the design

#2853 asks for credential profiles "following the reusable SSH profiles pattern". That pattern does not work the way it reads.

SSHTunnelMode.profile(id:snapshot:) freezes a whole SSHConfiguration into the connection when the form saves, and DatabaseManager+SSH.swift connects from that frozen copy. Only the secrets were ever read back from the profile. So editing a profile's host changed nothing for any connection already using it: it kept tunnelling to the old host while sending the profile's new password. Nothing in the app ever rewrote that snapshot, on this Mac or on a Mac the edit synced to.

Copying that shape for credentials would have shipped a profile whose username never updates, which is exactly what the issue asks for and does not get.

So the snapshot becomes a materialized copy with a fan-out behind it. SSHProfile.applied(to:) is the single pure transform; SSHProfileStorage.updateProfile writes it into every linked connection, SyncCoordinator.applyRemoteSSHProfile does the same for an edit that arrived from another Mac, and DatabaseManager.buildEffectiveConnection resolves against the profile directly, so the connect is right even in the window before a fan-out has run.

What else was wrong here

Defect Failure
Deleting a profile left its connections addressing a profile id that no longer resolved The delete alert said they would "fall back to no SSH tunnel". They did not: the frozen snapshot still had enabled = true, a host and a username. Now the delete hands each connection that configuration and its secrets as its own inline tunnel.
A remote delete left all three of the profile's Keychain items behind SyncCoordinator dropped the record and called saveProfilesWithoutSync, nothing else. Those keys are written and deleted in one place each, both reached only from deleteProfile, so nothing left could name them.
The profile editor reported saves that never happened saveProfiles returned Void and exited early on a failed load. Create, rename and delete all closed the sheet and ran onSave, having already written the Keychain items for a profile that was never persisted. It returns Bool now and the editor surfaces the failure.
Profile secrets were written to the real login Keychain under test isolation SSHProfileStorage took KeychainHelper.shared concretely rather than AppStorageEnvironment.shared.keychain, which is the injection ConnectionStorage already has.
Clearing a password left the old one stored and in use ConnectionFormCoordinator had no arm for empty-and-not-prompting, while AuthPaneViewModel prefills the field from the Keychain. The next connect still authenticated with the old password, an encrypted export still carried it and a duplicate copied it. Same hole two lines down for the inline SSH password and key passphrase.
A SqlPackage restore put the password in argv with nothing said The exposure consent lived in BackupDatabaseFlow alone. RestoreDatabaseFlow launches the same tool through the same NativeDumpService.start, after an alert about overwriting data that says nothing about the command line. NativeDumpPasswordExposure is now the one owner and both flows ask.
Backups ran with no password on a connection that has one NativeDumpService read the Keychain directly, so a connection whose password comes from a file, a shell command, 1Password, Vault, AWS Secrets Manager or ~/.pgpass dumped with an empty password against a server the app itself was connected to. The SqlPackage password-exposure warning was skipped for the same connections, by the same test.
iOS deleted saved passwords out of iCloud Keychain KeychainSecureStore.cleanOrphanedCredentials deletes every com.TablePro.password.<uuid> whose UUID is not a locally saved connection, with kSecAttrSynchronizableAny, in the shared access group. It runs from AppState.init before sync is wired, so on a fresh install the valid set is empty and it sweeps everything, and the delete propagates to the Mac that wrote it. It now returns on an empty set and only touches device-local items.

The last one is also a hard constraint on the feature this unblocks: a credential profile cannot key its Keychain item com.TablePro.password.<profileId>, because a profile id is never a connection id.

The seam

ConnectionCredentialResolver now owns the five places a password can come from, and connect, NativeDumpService and the SqlPackage warning all ask it the same question. DatabaseDriverFactory.resolvePassword delegates to it; resolvedAdditionalFields(for:) is what lets a non-driver caller build the same field set.

Review

Codex reviewed the working tree and returned eight findings, all real and all fixed in this branch: the delete converting a stale snapshot while handing over the current password; the restore consent above; failing open when the consent lookup throws; bypassing mutateConnections and its notification; deleting secrets before the connection write that justifies them; ignoring a failed unlink during a remote delete; treating an unreadable keychain as "no secret" while deleting the source; and swallowing the resolver's error into a misleading authentication failure.

Skill(security-review) then found nothing at confidence 8 or above. It confirmed ConnectionCredentialResolver.resolvePassword is byte-for-byte the original including the storeIsTrusted gate ahead of PasswordSourceResolver.resolve, that the new callers cannot reach .command(shell:) around it, and that no added log line or user-facing string carries a secret. Its one sub-threshold note, copied secrets left behind when a conversion fails, is fixed too.

Verification

  • verify.sh build PASS
  • verify.sh test on the four new suites: 32 cases, 32 passed
  • verify.sh test on the neighbouring suites that own the changed types
  • verify.sh lint TablePro TableProTests TableProMobile
  • verify.sh docs

New tests: SSHProfileAppliedTests (the pure transform: refresh, preserved remote-file fields, other profiles and inline tunnels left alone), SSHProfileStorageTests (fan-out, unlink on delete, secret adoption, tombstone ordering, failure propagation), StoredSecretStateTests and ClearedSecretSaveTests (the tri-state, including that a locked or cancelled Keychain never causes a delete). SSHProfileStorage had no test suite at all before this.

No UI automation: every flow here is a storage or resolution path with no new control. The SSH profile editor's failure banner is the one visible change and it needs an unwritable defaults suite to appear, which XCUITest cannot arrange against the app under test.

Not in this PR

The credential profile itself, its Settings pane and the shared picker (PR 2), and sync, export/import and iOS (PR 3).

@mintlify

mintlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
TablePro 🟢 Ready View Preview Sep 15, 2026, 2:41 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

This branch was successfully deployed

1 active deployment
staging - docs — 009670fb Deployed Sep 15, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant