Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions CONNECTION_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ by the struct it lives on. `ConnectionConfig` and `AuthConfig` are
| [`AuthConfig`](#authconfig--authentication-required) | PAT / OAuth M2M / OAuth U2M *(required)* |
| [`DefaultOpts`](#defaultopts--session-defaults-optional) | default catalog / schema, transactions |
| [`HttpConfig`](#httpconfig--http-client-optional) | timeouts, connection pool, retries, headers |
| [`ProxyConfig`](#proxyconfig--httphttps-proxy-optional) | HTTP/HTTPS proxy |
| [`ProxyConfig`](#proxyconfig--httphttps-proxy-optional) | HTTP/HTTPS/SOCKS proxy |
| [`TlsConfig`](#tlsconfig--tls--ssl-optional) | cert validation, custom CA, mTLS |
| [`ResultConfig`](#resultconfig--result-handling-optional) | CloudFetch tuning, type rendering |
| [`geospatial_result_representation`](#geospatial_result_representation--geospatial-result-encoding-optional) | GEOMETRY / GEOGRAPHY result encoding |
Expand Down Expand Up @@ -178,13 +178,30 @@ until implemented) and `External` (a caller-supplied `TokenProvider`).
## `ProxyConfig` — HTTP/HTTPS proxy (optional)

When `url` is `None`, the kernel does not configure a proxy and
`reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` env-var
behaviour applies. Setting `url` **overrides** those env vars.
`reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY`
env-var behaviour applies. Those variables are used only with the `http`,
`https`, `socks4`, `socks4a`, `socks5` and `socks5h` schemes. A value with
any other scheme, such as bare `socks://`, is ignored, so the kernel falls
back to `ALL_PROXY` or connects directly. Setting `url` **overrides** those
env vars, and an unsupported scheme in `url` fails with `InvalidArgument`.

SOCKS: `socks5://` and `socks4://` resolve the target host locally;
`socks5h://` and `socks4a://` let the proxy resolve it. SOCKS5 credentials
use RFC 1929 username/password authentication. When credentials are set,
that is the only method offered, so a proxy that allows only
unauthenticated access rejects the connection. SOCKS4 has no password, and
the kernel does not yet send a SOCKS4 user ID, so a SOCKS4 proxy that checks
the user ID refuses the connection. An unreachable proxy fails the request
after the retry policy's attempts; a rejected SOCKS5 authentication fails it
at once, without resending the credentials. The kernel never falls back to a
direct connection. TLS is still negotiated with, and verified against, the target
host through the tunnel. Proxy URLs are logged and reported in errors with
userinfo replaced by `***`.

| Field | Description | Default |
|-------|-------------|---------|
| `url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080`. Must be `http://` or `https://`. | `None` (env-var behaviour) |
| `username` | Proxy basic-auth username. Overrides credentials embedded in `url`. | `None` |
| `url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080` or `socks5h://proxy.corp.example.com:1080`. Scheme must be `http`, `https`, `socks4`, `socks4a`, `socks5` or `socks5h`. | `None` (env-var behaviour) |
| `username` | Proxy basic-auth (SOCKS5: RFC 1929) username. Overrides credentials embedded in `url`. | `None` |
| `password` | Proxy basic-auth password. Ignored unless `username` is set. Redacted in `Debug`. | `None` |
| `bypass_hosts` | Comma-separated hosts/domains to bypass the proxy, e.g. `localhost,*.internal.corp,.example.com`. | `None` |

Expand Down
28 changes: 18 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ arrow-ipc = "59"
# (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"] }
#
# `socks` adds SOCKS4/4a/5/5h proxies. From 0.12.28 it is implemented by
# hyper-util (already a dependency) and pulls in no extra crate.
reqwest = { version = "0.12.28", default-features = false, features = ["json", "gzip", "stream", "socks"] }
Comment thread
cathleeny marked this conversation as resolved.
Resolved
# Enforce the SOCKS4/4a fix for consumers with their own lockfiles: hyper-util
# 0.1.20 writes a malformed SOCKS4 CONNECT request.
hyper-util = { version = "0.1.21", default-features = false }
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.
Expand Down
5 changes: 5 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ changes go in their respective binding's NEXT_CHANGELOG.
`kernel_session_config_set_port` connect to `host:port`, so bindings no longer
build it into the host. A non-default port is rejected with `InvalidArgument`
if the host has credentials, a path, query or fragment.
- `ProxyConfig.url`, the Rust ADBC driver's `adbc.databricks.proxy.url`,
`HTTPS_PROXY` and `ALL_PROXY` accept SOCKS4 and SOCKS5 proxy URLs.

### Changed

- Proxy credentials are redacted from proxy URLs in errors, logs and `Debug`
output.

### Updated

### Fixed
Expand Down
1 change: 1 addition & 0 deletions adbc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 35 additions & 2 deletions adbc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,13 @@ impl DatabaseConfig {
));
}
if let Some(url) = &self.proxy.url {
if !(url.starts_with("http://") || url.starts_with("https://")) {
const SCHEMES: [&str; 6] = ["http", "https", "socks4", "socks4a", "socks5", "socks5h"];
if !url
.split_once("://")
.is_some_and(|(scheme, _)| SCHEMES.contains(&scheme))
{
return Err(adbc_error(
"proxy URL must use http or https",
"proxy URL must use http, https, socks4, socks4a, socks5 or socks5h",
Status::InvalidArguments,
));
}
Expand Down Expand Up @@ -1370,6 +1374,35 @@ mod tests {
assert!(config.validate().is_ok());
}

#[test]
fn proxy_url_accepts_http_and_socks_schemes() {
for (url, accepted) in [
("http://proxy.example.com:8080", true),
("https://proxy.example.com:8443", true),
("socks4://proxy.example.com:1080", true),
("socks4a://proxy.example.com:1080", true),
("socks5://proxy.example.com:1080", true),
("socks5h://proxy.example.com:1080", true),
("socks://proxy.example.com:1080", false),
("SOCKS5://proxy.example.com:1080", false),
("ftp://proxy.example.com:21", false),
("proxy.example.com:1080", false),
// SOCKS credentials still go through the username/password options.
("socks5h://user:secret@proxy.example.com:1080", false),
] {
let mut config = DatabaseConfig::default();
set(&mut config, "adbc.databricks.proxy.url", url);
match config.validate() {
Ok(_) => assert!(accepted, "{url} must be rejected"),
Err(error) => {
assert!(!accepted, "{url} must be accepted: {}", error.message);
assert_eq!(error.status, Status::InvalidArguments, "{url}");
assert!(!error.message.contains("secret"), "{url}");
}
}
}
}

#[test]
fn proxy_basic_auth_reaches_kernel_config() {
let mut config = DatabaseConfig::default();
Expand Down
7 changes: 4 additions & 3 deletions include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,10 @@ KernelStatusCode kernel_init_logging_callback(const char* level,
* override.
*/

/* Route traffic through an HTTP/HTTPS proxy. `url` is required (e.g.
* "http://proxy.corp:8080"); `username` / `password` / `bypass_hosts`
* (comma-separated) are optional — pass NULL to omit. */
/* Route traffic through an HTTP/HTTPS or SOCKS proxy. `url` is required
* (e.g. "http://proxy.corp:8080" or "socks5h://proxy.corp:1080"; schemes
* http, https, socks4, socks4a, socks5, socks5h); `username` / `password` /
* `bypass_hosts` (comma-separated) are optional — pass NULL to omit. */
KernelStatusCode kernel_session_config_set_proxy(KernelSessionConfig* config, const char* url,
const char* username, const char* password,
const char* bypass_hosts);
Expand Down
28 changes: 18 additions & 10 deletions napi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions napi/NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ layout, or npm publishing. Pure-kernel changes go in the root

### Updated

- Bundle the kernel's SOCKS proxy support.
Comment thread
cathleeny marked this conversation as resolved.
Resolved

### Fixed

---
Expand Down
5 changes: 3 additions & 2 deletions napi/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ export interface HeaderEntry {
value: string
}
/**
* Programmatic HTTP/HTTPS proxy configuration, mirroring the kernel's
* Programmatic HTTP/HTTPS/SOCKS proxy configuration, mirroring the kernel's
* internal [`ProxyConfig`]. Supplied as a structured object rather than a
* flattened URL so credentials never have to be percent-encoded into the URL
* and the bypass-host list can be expressed.
*
* - `url` — proxy endpoint, e.g. `"http://proxy.corp.example.com:8080"`. Must
* use the `http://` or `https://` scheme.
* use the `http://`, `https://`, `socks4://`, `socks4a://`, `socks5://` or
* `socks5h://` scheme.
* - `username` / `password` — optional proxy basic-auth, applied via
* `reqwest`'s `Proxy::basic_auth` (not embedded in the URL).
* - `bypassHosts` — optional comma-separated host/domain list that should
Expand Down
Loading
Loading