Skip to content

Commit 30df76c

Browse files
committed
fix(credentials): describe saved-connection TLS modes as the drivers apply them
- MySQL Required verifies the certificate chain but not the host name (like VERIFY_CA), and both Preferred and Required refuse a server without TLS. - SQL Server Encrypt connection requests TLS; a server that does not support encryption gets an unencrypted session rather than an error. - PostgreSQL Preferred can be downgraded by an on-path attacker, so the hint and docs steer to Required when the server supports TLS. - Picker options are keyed by each operation schema's value type, so a mode the operations add or drop fails to compile instead of drifting.
1 parent c9326b8 commit 30df76c

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

‎apps/docs/content/docs/integrations/mssql.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Use [Microsoft SQL Server](https://www.microsoft.com/sql-server) to query or mod
1616

1717
In **Integrations**, add a connection with the host, port, database, username, password, and transport-security settings. Sim proves the connection with `SELECT 1` before saving it encrypted, then reads it on the server for each run; the block, the workflow, and agents never see the password. Reconnect the connection from Integrations when its credentials change. The runtime must be able to reach the database host.
1818

19-
- **Encrypt connection** encrypts the connection with TLS; leave it enabled.
19+
- **Encrypt connection** requests TLS; leave it enabled. A server that does not support encryption gets an unencrypted session rather than an error, so confirm the server has encryption on.
2020
- **Trust server certificate** skips certificate validation. Enable it only for a server with a self-signed certificate you trust.
2121
- Named instances are not supported; give the instance a static TCP port and connect to that port.
2222

‎apps/docs/content/docs/integrations/mysql.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Query returns rows and a row count. Insert, update, and delete operations accept
1919
In **Integrations**, add a connection with the host, port, database, username, password, and transport-security settings. Sim proves the connection with `SELECT 1` before saving it encrypted, then reads it on the server for each run; the block, the workflow, and agents never see the password. Reconnect the connection from Integrations when its credentials change. The runtime must be able to reach the database host.
2020

2121
- **Preferred** encrypts without verifying the server certificate.
22-
- **Required** encrypts and verifies the server certificate against the runtime's trust store.
22+
- **Required** encrypts and verifies the certificate chain against the runtime's trust store, but does not check the host name, like MySQL's `VERIFY_CA`.
23+
- Both refuse a server that offers no TLS rather than connect unencrypted, so Sim's **Preferred** behaves like MySQL's `REQUIRED`, not its `PREFERRED`.
2324
- **Disabled** never encrypts. Use it only on a network whose confidentiality you control.
2425

2526
Workflows built before saved connections keep their inline connection fields and run unchanged.

‎apps/docs/content/docs/integrations/postgresql.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Use [PostgreSQL](https://www.postgresql.org/) to query and modify rows, execute
1616

1717
In **Integrations**, add a connection with the host, port, database, username, password, and transport-security settings. Sim proves the connection with `SELECT 1` before saving it encrypted, then reads it on the server for each run; the block, the workflow, and agents never see the password. Reconnect the connection from Integrations when its credentials change. The runtime must be able to reach the database host.
1818

19-
- **Preferred** encrypts when the server offers TLS and otherwise connects without it.
19+
- **Preferred** encrypts when the server offers TLS and otherwise connects without it. An attacker on the network can force that fallback, so choose **Required** when the server supports TLS.
2020
- **Required** always encrypts but does not verify the server certificate, like libpq's `sslmode=require`.
2121
- **Disabled** never encrypts. Use it only on a network whose confidentiality you control.
2222

‎apps/sim/lib/credentials/database-connections/descriptors.ts‎

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* Server-side verification and resolution live in
1111
* `@/lib/credentials/database-connections/server`.
1212
*/
13+
import type { MssqlToggle } from '@/lib/internal/mssql/schema'
14+
import type { MysqlSslMode } from '@/lib/internal/mysql/schema'
15+
import type { PostgresqlSslMode } from '@/lib/internal/postgresql/schema'
1316
import {
1417
MSSQL_SERVICE_ACCOUNT_PROVIDER_ID,
1518
MYSQL_SERVICE_ACCOUNT_PROVIDER_ID,
@@ -43,16 +46,14 @@ export interface DatabaseConnectionDescriptor {
4346
docsUrl: string
4447
}
4548

46-
const SSL_MODE_OPTIONS = [
47-
{ value: 'preferred', label: 'Preferred' },
48-
{ value: 'required', label: 'Required' },
49-
{ value: 'disabled', label: 'Disabled' },
50-
] as const
51-
52-
const TOGGLE_OPTIONS = [
53-
{ value: 'enabled', label: 'Enabled' },
54-
{ value: 'disabled', label: 'Disabled' },
55-
] as const
49+
/**
50+
* Picker options in display order. Keyed by the operation schema's own value
51+
* type, so a value the operations add or drop fails to compile here instead of
52+
* drifting between the picker and what a save accepts.
53+
*/
54+
function optionsFrom<Value extends string>(labels: Record<Value, string>) {
55+
return Object.entries<string>(labels).map(([value, label]) => ({ value, label }))
56+
}
5657

5758
export const DATABASE_CONNECTION_DESCRIPTORS: Record<
5859
DatabaseConnectionProviderId,
@@ -68,9 +69,13 @@ export const DATABASE_CONNECTION_DESCRIPTORS: Record<
6869
{
6970
id: 'ssl',
7071
label: 'SSL mode',
71-
options: SSL_MODE_OPTIONS,
72-
defaultValue: 'preferred',
73-
hint: 'Required encrypts the connection without verifying the server certificate; Preferred falls back to an unencrypted connection when the server offers no TLS.',
72+
options: optionsFrom<PostgresqlSslMode>({
73+
preferred: 'Preferred',
74+
required: 'Required',
75+
disabled: 'Disabled',
76+
}),
77+
defaultValue: 'preferred' satisfies PostgresqlSslMode,
78+
hint: 'Required encrypts the connection without verifying the server certificate. Preferred falls back to an unencrypted connection when the server offers no TLS, which an attacker on the network can force; choose Required when the server supports TLS.',
7479
},
7580
],
7681
docsUrl: 'https://docs.sim.ai/integrations/postgresql',
@@ -85,9 +90,13 @@ export const DATABASE_CONNECTION_DESCRIPTORS: Record<
8590
{
8691
id: 'ssl',
8792
label: 'SSL mode',
88-
options: SSL_MODE_OPTIONS,
89-
defaultValue: 'preferred',
90-
hint: 'Required encrypts the connection and verifies the server certificate; Preferred encrypts without verifying it.',
93+
options: optionsFrom<MysqlSslMode>({
94+
preferred: 'Preferred',
95+
required: 'Required',
96+
disabled: 'Disabled',
97+
}),
98+
defaultValue: 'preferred' satisfies MysqlSslMode,
99+
hint: "Required encrypts the connection and verifies the certificate chain against the runtime's trust store, but not the host name (like MySQL's VERIFY_CA). Preferred encrypts without verifying the certificate. Both refuse a server that offers no TLS rather than connect unencrypted.",
91100
},
92101
],
93102
docsUrl: 'https://docs.sim.ai/integrations/mysql',
@@ -102,15 +111,15 @@ export const DATABASE_CONNECTION_DESCRIPTORS: Record<
102111
{
103112
id: 'encrypt',
104113
label: 'Encrypt connection',
105-
options: TOGGLE_OPTIONS,
106-
defaultValue: 'enabled',
107-
hint: 'Encrypts the connection with TLS.',
114+
options: optionsFrom<MssqlToggle>({ enabled: 'Enabled', disabled: 'Disabled' }),
115+
defaultValue: 'enabled' satisfies MssqlToggle,
116+
hint: 'Requests TLS. A server that does not support encryption gets an unencrypted session rather than an error.',
108117
},
109118
{
110119
id: 'trustServerCertificate',
111120
label: 'Trust server certificate',
112-
options: [...TOGGLE_OPTIONS].reverse(),
113-
defaultValue: 'disabled',
121+
options: optionsFrom<MssqlToggle>({ disabled: 'Disabled', enabled: 'Enabled' }),
122+
defaultValue: 'disabled' satisfies MssqlToggle,
114123
hint: 'Enable only for a server with a self-signed certificate; it skips certificate validation.',
115124
},
116125
],

0 commit comments

Comments
 (0)