NO-SNOW: add Snowflake DSN connection-string parser to sf_core - #1336
Open
zeroshade wants to merge 2 commits into
Open
NO-SNOW: add Snowflake DSN connection-string parser to sf_core#1336zeroshade wants to merge 2 commits into
zeroshade wants to merge 2 commits into
Conversation
Add config::dsn::parse_dsn to decompose user[:password]@account/db/schema style connection strings (with an optional snowflake:// prefix) into canonical sf_core connection parameters. Only parameters sf_core recognizes are emitted; unsupported/unknown keys are collected as warnings. Re-exported from the config module.
The malformed-parameter warning previously echoed the raw query segment; a fat-fingered token/password passed as a segment without '=' could leak into warnings. Omit the segment content and only note that a malformed parameter was dropped. Updates the corresponding unit test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a Snowflake DSN connection-string parser to
sf_core. A newconfig::dsn::parse_dsndecomposesuser[:password]@account/db/schema-style connection strings — with an optional, case-insensitivesnowflake://prefix so the same string can be written as a full URL — into sf_core's canonical connection parameters, returningParsedDsn { params, warnings }, and is re-exported from theconfigmodule. It supports the three documented DSN forms (.../db/schema,.../db, andhost:port/db/schema?account=...). Only parameters sf_core actually recognizes are emitted; every other key (format-only options,region, OCSP toggles, unknown keys) is dropped and surfaced inwarnings.The motivation is to give the language wrappers (Go, ODBC, Python, JDBC) a single-string connect affordance without each reimplementing the DSN grammar. Centralizing the parse in the core keeps the connection-string vocabulary in one tested place and lets every wrapper share identical semantics.
The parser is a pure function that feeds the existing
connection_set_options->resolver::resolvepipeline, so alias resolution, host derivation, and validation are unchanged — it deliberately does not build hostnames or bypass the downstreamis_allowed_account_charallow-list. It is hand-rolled with a single code path: the optionalsnowflake://prefix is stripped rather than routed throughurl::Url, guaranteeing byte-for-byte identical results with or without the prefix. User, password, database, schema, and query values are URL-unescaped (%XXand+->space) whileaccountandhostare taken verbatim, matching the reference DSN behavior; host derivation fromaccountremains the resolver's responsibility.Risk is low: the change is an additive module with no edits to existing connection, auth, or validation logic. Because the input is an untrusted connection string, credential handling was given particular attention — error variants and warnings never echo a decoded value (only keys or static labels), the
InvalidPortpath is redacted so a mistypeduser:secretcannot leak, ports are range-validated asu16, and an emptyaccount=no longer satisfies the account requirement.Testing: 25 unit tests cover the three forms, prefix parity and case-insensitivity, unescaping and
+->space, every supported mapping (including the inverted CRL-cache booleans andcertRevocationCheckMode), credential redaction, empty-account handling, and port validation;cargo test -p sf_core --lib configpasses 380/380. The change was reviewed with roborev (security review passed; the default review's single finding — thatrequestTimeoutshould map torequest_timeout— was verified againstretry.rsas a name-based false positive, sincequery_timeoutis sf_core's query-execution budget whilerequest_timeoutis the non-query HTTP retry budget that query execution deliberately ignores; documented and closed).Not included here: an optional
Connection::apply_dsnconvenience / protobuf RPC for wrapper wiring, and defense-in-depth non-emptyaccountvalidation inconnection_config.