Repository navigation
Expand file tree
/
Copy pathCargo.toml
More file actions
261 lines (241 loc) · 12.2 KB
/
Copy pathCargo.toml
File metadata and controls
261 lines (241 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# Copyright (c) 2026 Databricks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[package]
name = "databricks-sql-kernel"
version = "1.5.0"
edition = "2021"
authors = ["Databricks"]
license = "Apache-2.0"
description = "Databricks SQL Kernel — Rust client core for Databricks SQL drivers"
repository = "https://github.com/databricks/databricks-sql-kernel"
keywords = ["databricks", "arrow", "database", "sql"]
categories = ["database"]
include = [
"/src/**",
"/include/**",
"/tests/**",
"/docs/spec-v0.md",
"/docs/release-debuginfo.md",
"/Cargo.toml",
"/Cargo.lock",
"/README.md",
"/CHANGELOG.md",
"/CONNECTION_PARAMETERS.md",
"/LICENSE",
"/NOTICE",
]
[dependencies]
# The `log` feature makes `tracing::*` macros also emit `log::Record`s
# *when no tracing Subscriber is installed*. The pyo3 binding relies on
# this: it installs no Subscriber and instead routes those `log` records
# into Python's `logging` via `pyo3-log` (see `pyo3/src/logging.rs`).
# Direct-Rust / C-ABI consumers install the `fmt` Subscriber in
# `src/logging.rs` instead, which suppresses the `log` records — the two
# paths are mutually exclusive by construction.
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
# `ffi` enables the Arrow C Data Interface (`FFI_ArrowArray` /
# `FFI_ArrowSchema`, `to_ffi`) used by the C ABI's result-stream export
# (`src/ffi/result.rs`) so ODBC / Go consumers can pull result batches
# across the boundary without re-encoding.
arrow-array = { version = "59", features = ["ffi"] }
arrow-buffer = "59"
arrow-cast = "59"
arrow-ord = "59"
arrow-schema = "59"
arrow-select = "59"
arrow-ipc = "59"
# HTTP client and async runtime
#
# TLS backend is selected by Cargo features (see `[features]` below).
# Default = `tls-native` to preserve compatibility for direct-Rust and
# C-ABI consumers (e.g. future ODBC), which historically use the system
# OpenSSL via `native-tls`.
#
# The napi-rs binding crate (`napi/`) opts INTO `tls-rustls` instead:
# napi modules are loaded into Node.js processes that statically link
# OpenSSL 3.x, and dynamically linking against the system's OpenSSL 1.1
# (which `native-tls` pulls in on Linux) collides with Node's symbols at
# module load time and segfaults the process before any Rust code runs.
# `rustls` is pure Rust + ring and avoids the conflict entirely.
reqwest = { version = "0.12", default-features = false, features = ["json", "gzip", "stream"] }
native-tls = { version = "0.2", optional = true }
rustls = { version = "0.23.41", optional = true, default-features = false, features = ["ring", "std", "tls12"] }
# Enforce TLS dependency minimums for consumers with their own lockfiles.
rustls-webpki = { version = "0.103.16", optional = true, default-features = false }
webpki-roots = { version = "1.0.11", optional = true, default-features = false }
tokio = { version = "1", features = ["full", "sync"] }
# Serialization
serde = { version = "1", features = ["derive"] }
serde_json = "1"
base64 = "0.22"
hex = "0.4" # Hex encoding (binary param literals, token cache key)
wkb = "0.9.2" # OGC WKB parser for geospatial result rendering
geo-traits = "0.3" # Generic geometry traversal for WKB-to-EWKT rendering
wkt = { version = "0.14", default-features = false } # OGC WKT parser for legacy SEA results
# Date/time handling
chrono = { version = "0.4", features = ["serde"] }
# LZ4 decompression for CloudFetch
lz4_flex = "0.14"
# Random number generation (retry jitter)
rand = "0.10"
# Concurrent data structures
dashmap = "6"
moka = { version = "0.12.16", features = ["future"] }
# Async utilities
futures = "0.3"
tokio-util = "0.7"
async-trait = "0.1"
# Error handling
thiserror = "2"
# OAuth dependencies
#
# oauth2 5.x enables `default = ["reqwest", "rustls-tls"]`, which would
# silently pull `reqwest/rustls-tls` into the kernel build and unify
# both TLS stacks even when the consumer asked for only `tls-native`.
# Strip defaults and re-enable just the `reqwest` integration here; the
# kernel's own `tls-native` / `tls-rustls` feature controls the TLS
# backend for reqwest, and oauth2 inherits whichever the consumer picks.
oauth2 = { version = "5", default-features = false, features = ["reqwest"] } # OAuth 2.0 protocol operations (PKCE, token exchange, client credentials)
sha2 = "0.11" # SHA-256 for token cache key generation
open = "5" # Browser launch for interactive OAuth flows
dirs = "6" # Cross-platform config directory (~/.config/)
# Token-cache encryption at rest. The cached OAuth payload holds a
# long-lived refresh token, so it is encrypted with AES-256-CBC under a
# PBKDF2-HMAC-SHA256 key derived from a caller-supplied passphrase. The
# parameters mirror the JDBC driver's EncryptedFileTokenCache so both
# drivers give the same file the same protection. All four are RustCrypto
# crates, dual Apache-2.0/MIT (both already allow-listed in deny.toml).
aes = { version = "0.9.2", features = ["zeroize"] } # AES-256 block cipher
cbc = { version = "0.2.1", features = ["alloc", "block-padding", "zeroize"] } # CBC mode + PKCS#7 padding
pbkdf2 = { version = "0.13.0", default-features = false, features = ["hmac"] } # Passphrase-based key derivation
hmac = "0.13.0" # PRF backing PBKDF2
zeroize = "1.9" # Wipe derived key material on drop
# JWT private-key client-credentials auth (service-principal M2M with a
# signed client assertion instead of a client secret). Mirrors the JDBC
# driver's JwtPrivateKeyClientCredentials. We sign with `jsonwebtoken`
# (RS/PS/ES families, backed by `ring` — already in the graph via rustls,
# so this adds no new heavyweight dependency) and load PEM/PKCS#8 keys
# with the RustCrypto `pkcs8`/`sec1` family. This deliberately avoids the
# `openssl` crate to preserve the pure-Rust/rustls posture the napi
# binding depends on (see the `reqwest` / `[features]` TLS notes above);
# the one accepted gap vs. JDBC/BouncyCastle is ES512 (P-521), which
# `ring` does not support. All crates are dual Apache-2.0/MIT.
#
# Pinned to 9.x deliberately. jsonwebtoken 10.x dropped the built-in
# `ring` backend and forces an explicit crypto backend, both of which
# regress us: `rust_crypto` pulls `rsa` (RUSTSEC-2023-0071, Marvin) into
# the RUNTIME crate, and `aws_lc_rs` links a C library (AWS-LC) that
# breaks the pure-Rust posture and adds a recurring C-CVE maintenance
# tail. 9.x's advisory GHSA-h395-gr6q-cpjc is in the DECODE/validation
# path, which the kernel never exercises (it only signs), so it is
# suppressed with justification in `osv-scanner.toml` rather than paying
# the 10.x cost. Revisit if jsonwebtoken ships a ring-backed 10.x.
jsonwebtoken = { version = "9", default-features = false, features = ["use_pem"] } # JWT signing (RS256/384/512, PS256/384/512, ES256/384); use_pem = PEM key loading (adds pem + simple_asn1, no TLS)
pkcs8 = { version = "0.10", features = ["encryption", "pem", "std"] } # PKCS#8 PEM parsing + PBES2 passphrase decryption
# `pthread_sigmask` for kernel-owned runtime threads (`src/util/runtime.rs`).
# Already in the graph through tokio, so no new crate is added.
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[dev-dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util"] }
wiremock = "0.6"
tempfile = "3"
log = "0.4"
# Generate JWT test keys in-process to avoid PEM fixtures and an external
# `openssl` dependency. `ring` already backs runtime JWT signing.
rsa = { version = "0.9", features = ["pem"] }
ring = "0.17"
# Hermetic mTLS C-ABI tests generate a private CA and client/server identities
# at runtime, then serve HTTPS with mandatory client-certificate verification.
# This avoids committed credentials, external processes, and live workspaces.
rcgen = "0.14.9"
rustls = { version = "0.23.41", default-features = false, features = ["ring", "std", "tls12"] }
tokio-rustls = { version = "0.26.4", default-features = false, features = ["ring", "tls12"] }
# TLS backend selection.
#
# Default is `tls-native` (reqwest's `native-tls` backend) to preserve
# compatibility for direct-Rust use and the C-ABI / ODBC path. The napi
# binding crate (`napi/`) sets `default-features = false` on the kernel
# dependency and explicitly enables `tls-rustls` instead, to avoid the
# OpenSSL-symbol clash with the host Node.js process at module load
# time.
#
# These features are MUTUALLY EXCLUSIVE in intent: a binary that ends
# up with both `reqwest/native-tls` AND `reqwest/rustls-tls` active
# links both TLS stacks. In a napi cdylib that defeats the whole reason
# for the rustls switch — system OpenSSL gets linked in anyway and
# clashes with Node.js's statically linked OpenSSL at module load.
#
# Mutual exclusivity is enforced two ways:
#
# 1. `src/lib.rs` has `compile_error!` guards that fail the build if
# both features are active OR if neither is (a consumer who set
# `default-features = false` and forgot to opt back in).
#
# 2. The kernel's own oauth2 dep uses `default-features = false` so
# that the kernel workspace doesn't transitively enable rustls via
# oauth2's own default features. Without this, `cargo tree -i
# reqwest -f "{p} {f}"` showed rustls-tls active even in the pure
# `tls-native` build (oauth2 5.x defaults are
# `["reqwest", "rustls-tls"]`).
#
# The napi crate also lives in its own workspace (not a member of this
# kernel workspace) so it can pin different transitive feature choices,
# but that separation is no longer load-bearing for the TLS feature
# guarantee — items 1 and 2 above are.
[features]
default = ["tls-native"]
tls-native = ["reqwest/native-tls", "dep:native-tls"]
# `rustls-tls` alone is `reqwest/rustls-tls-webpki-roots` — the bundled Mozilla
# root set only, which does NOT read the OS system trust store. `tls-native`
# (native-tls → OpenSSL) DOES read `/etc/ssl/...`, so a `tls-rustls` build behind
# a private/internal CA installed only in the OS store fails a handshake that the
# `tls-native` build completes. Enabling `rustls-tls-native-roots` alongside makes
# reqwest load the OS trust store AND the Mozilla bundled roots into one
# `RootCertStore` (both `tls_built_in_certs_*` default true → additive, no
# fallback lost). This gives the aarch64 cross-build — the only Linux arch on
# `tls-rustls` — system-CA parity with the x86_64/i686 OpenSSL builds. See
# odbc#323.
tls-rustls = [
"reqwest/rustls-tls",
"reqwest/rustls-tls-native-roots",
"dep:rustls",
"dep:rustls-webpki",
"dep:webpki-roots",
]
[lib]
name = "databricks_sql_kernel"
crate-type = ["lib", "cdylib", "staticlib"]
# Workspace — the kernel is its own single-member workspace root.
#
# `adbc/`, `pyo3/`, and `napi/` are not members. The bindings require their
# own build and lockfile boundaries; pyo3 and napi also opt INTO
# `tls-rustls` (see the `[features]` comment above for why), while
# the kernel itself defaults to `tls-native` for direct-Rust / C-ABI
# consumers. A single-workspace build would unify the kernel's
# feature set to `tls-native ∪ tls-rustls` across all members,
# trip the mutual-exclusion `compile_error!` in `src/lib.rs`, and
# defeat the per-binding TLS choice. Each sub-crate therefore declares
# its own `[workspace]` and reaches the kernel via `path = ".."` — same
# source tree, four independent workspace views.
[workspace]
members = ["."]
# Opt-in profile for native consumers that split private crash symbols from the
# shipped driver. Inheriting `release` is intentional: `debug` is the only
# override, so optimization, LTO, codegen units, panic behavior, overflow
# checks, and debug assertions remain identical to an ordinary release build.
[profile.release-with-debuginfo]
inherits = "release"
debug = 2