feat(presto/trino-driver): Support custom headers#10902
Conversation
|
Claude finished @ovr's task in 1m 53s —— View job Code Review: feat(presto/trino-driver): Support custom headers
SummaryClean, well-scoped feature that adds What looks good
Issues & Suggestions1. Security — no header key validation (medium) 2. Test coverage gaps (medium)
3. Unrelated formatting changes (low) 4. See inline comments for specific details on each file. |
7b87823 to
e518204
Compare
| queryTimeout?: number; | ||
| preAggregations?: boolean; | ||
| // @see https://trino.io/docs/current/develop/client-protocol.html | ||
| headers?: Record<string, string>; |
There was a problem hiding this comment.
Security concern: The headers config is spread into new presto.Client({ ...this.config }) at line 124-127, meaning headers is passed both at the client level and per-execute() call. This is likely harmless if the presto-client library ignores unknown options at the client level, but it's worth verifying there's no unintended double-application or conflict.
More importantly, there's no validation on the header keys/values. A user could potentially override critical protocol headers (e.g., Authorization, Content-Type, Host) which could cause unexpected behavior or security issues. Consider either:
- Documenting that overriding auth headers via
headersis unsupported, or - Adding a blocklist check to reject known sensitive headers like
Authorization.
| const protocol = ssl ? 'https' : 'http'; | ||
| const url = `${protocol}://${host}:${port}/v1/info`; | ||
| const headers: Record<string, string> = {}; | ||
| const headers: Record<string, string> = { ...extraHeaders }; |
There was a problem hiding this comment.
Good pattern — spreading extraHeaders first and then setting Authorization after means auth config always takes precedence over custom headers, which is the correct behavior. This prevents a custom header from accidentally (or maliciously) overriding the auth mechanism.
However, the inverse isn't true for the PrestoDriver's testConnection (inherited from base) — that path uses the presto-client library's nodes() call, which doesn't get the custom headers. So custom headers only work on the Trino side's testConnection. Worth noting in documentation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10902 +/- ##
===========================================
- Coverage 78.87% 58.38% -20.49%
===========================================
Files 470 216 -254
Lines 92439 16949 -75490
Branches 3435 3436 +1
===========================================
- Hits 72907 9895 -63012
+ Misses 19030 6552 -12478
Partials 502 502
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.