CE-1007: baton-sql library API (NewFromYAML + LookupFunc) - #142
Conversation
| database: ${DB_DATABASE} | ||
| user: ${DB_USER} | ||
| password: ${DB_PASSWORD} | ||
| params: |
There was a problem hiding this comment.
🟡 Suggestion: This "golden path" fixture connects over the public internet (the header comment notes the customer DB must allowlist ConductorOne egress IPs) but sets sslmode: disable, sending credentials and query data unencrypted. Consider sslmode: require (or stronger) as the reference default so downstream agent-authored configs don't inherit an insecure transport. (confidence: medium)
|
@- |
| user: | ||
| name: User | ||
| description: A user row in the database | ||
| list: |
There was a problem hiding this comment.
🟡 Suggestion: This golden fixture is documented as connecting from ConductorOne SaaS across the internet to a customer DB (egress-IP allowlisting comment above), yet sslmode: disable turns off TLS entirely — DB credentials and row data would transit in plaintext. Since golden examples tend to get copied verbatim, consider defaulting to sslmode: require (or verify-full) so the canonical path is TLS-on. (confidence: medium)
| varName := match[2 : len(match)-1] | ||
|
|
||
| value, exists := os.LookupEnv(varName) | ||
| value, exists := lookup(varName) |
There was a problem hiding this comment.
🟡 Suggestion: Now that LookupFunc backs this expansion, a map-based embedder (the new NewFromYAML path) that omits a key still gets environment variable %s is not set (line 81), which misdescribes the source as an env var. Consider a source-neutral message like placeholder ${%s} could not be resolved so library-embed errors read correctly. (confidence: medium)
Connector PR Review: CE-1007: baton-sql library API (NewFromYAML + LookupFunc)Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review SummaryFull PR diff scanned for security and correctness. This adds library-safe constructors ( Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
Add injectable LookupFunc for ${KEY} expansion (no process env mutation),
NewWithConfig/NewFromYAML for library embeds, OfflineValidate and
RejectNonV1ProductFeatures for editor/agent offline checks, and a C1
golden Postgres fixture with externalized map-value secrets.
CE-1007 / ds-663v
Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
6a6ee3b to
50e20c0
Compare
C1 SaaS / public-internet customer DBs should use TLS by default. disable remains documented only for non-TLS local lab DBs. ds-kjkw Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
| map: | ||
| id: ".username" | ||
| display_name: ".username" | ||
| description: ".email" |
There was a problem hiding this comment.
🟡 Suggestion: The query selects a stable u.id but the resource id maps to .username (a mutable field). If a user is renamed, C1 will see it as a delete + re-create, breaking grant continuity. Since this is the canonical golden fixture, consider mapping id: ".id" (keep display_name/login on .username) so the example demonstrates stable-ID practice. (confidence: medium)
Resource renames would otherwise surface as delete+create and break grant continuity. Keep display_name/login on .username. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
| params: | ||
| # require: default for C1 SaaS / public-internet customer DBs (TLS). | ||
| # disable: only for non-TLS local lab DBs — not the golden path. | ||
| sslmode: require |
There was a problem hiding this comment.
🟡 Suggestion (low confidence): sslmode=require encrypts the connection but does not verify the server certificate, so it does not protect against MITM on the path to a public-internet customer DB. Since this is a golden template customers will copy, consider verify-full (or verify-ca) for the SaaS default and reserving require for local labs. Non-blocking — this may be an intentional tradeoff if customers can't reliably provide root certs.
Summary
Library embed surface for C1 agent-authored SQL connectors (CE-1007 / ds-663v):
${KEY}expansion on connect fields/DSN (nil ->os.LookupEnvfor CLI)os.Setenv)postgresscheme includingpostgresql)examples/c1-golden-postgres.ymlwith map-value placeholder keys documentedNon-test production changes
PR: #142
HEAD:
50e20c0bBASE:
9f01eeb4Library-safe constructors so C1 can open a baton-sql connector from YAML bytes and resolve
${KEY}placeholders from a map, without writing secrets into process environment. CLINewstill expands from the environment. Separate offline validators encode the v1 product bar: Postgres, one database, sync-only.1.
pkg/database/database.goWhere:
LookupFunc~L28;ConnectOptions.Lookup~L59-60;resolveLookup~L63-68;updateFromLookup~L70-90;updateFromEnv~L94-96;extractPlaceholders~L102+;expandDSN~L292+;ResolveDatabaseName/buildConnectionURL/expandValuecall sites ~L357-607What changed
os.LookupEnv.ConnectOptionscarriesLookup. When it is nil, helpers still use process environment.Why
os.Setenvto make${KEY}work.2.
pkg/connector/connector.goWhere:
LookupFuncalias ~L108;New~L111-118;NewWithConfig~L122-127;NewFromYAML~L132-138;Config~L141-143;newConnector~L145-177What changed
Newstill loads a file and passes a nil lookup into the shared constructor.NewWithConfigbuilds from an already-parsed config with env expansion.NewFromYAMLparses YAML bytes and passes the caller lookup into connect options.Config()exposes the parsed config for host callers.newConnectorsetsConnectOptions.Lookupbefore opening databases.Why
3.
pkg/bsql/offline_validate.goWhere: new file;
OfflineValidate~L12-37;RejectNonV1ProductFeatures~L41-67;ValidateYAML~L70-76;validateConnectOffline~L78-92;resolveConnectScheme~L94-121What changed
postgresonly. Thepostgresqlalias fails the same check.Why
4.
examples/c1-golden-postgres.ymlWhere: whole file ~L1-53; connect placeholders ~L12-20;
userresource_type list/map ~L22-53What changed
${DB_*}placeholders, map-value key list in the header comment, one user list query with static member entitlement.Why
Excluded from detailed notes
pkg/bsql/offline_validate_test.gopkg/connector/connector_from_yaml_test.gopkg/database/database_test.gopkg/database/lookup_test.goCall graph (library path)
NewFromYAML->bsql.Parse->newConnector->ConnectOptions.Lookup->buildConnectionURL/expandDSNviaresolveLookup.CLI stays
New->newConnector(..., nil)->os.LookupEnv.OfflineValidate/ValidateYAMLare opt-in; not wired intoNew.Test plan
go test ./...Follow-up
c1 vendors this pin via
local_vendor/baton-sqland builds the SQL catalog HTTP twin.