fix(client): accept boolean TLS socket options#3307
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
|
Thanks @puneetdixit200, i will have a look. |
|
Thanks for the PR. The compile error on the Heroku pattern is real, but widening If you switch scheme dynamically, pass the |
Description
Fixes #3113.
RedisTlsOptionsrequiredsocket.tlsto be the literal typetrue, which rejected the common Heroku-style configuration where TLS is derived from the URL:This widens the TLS socket option type to accept a runtime boolean while preserving the existing runtime behavior:
RedisSocketstill creates a TLS socket only whenoptions?.tls === true.I also added a compile-time regression in the client type tests for the Heroku-style configuration.
Checklist
npm testpass with this change (including linting)?Verification:
npm run test:types -w @redis/clientnpm run buildnpm run lint:changedgit diff --checknpm exec -w @redis/client -- mocha -r tsx --exit './lib/client/socket.spec.ts' './lib/client/index.spec.ts'ran until Redis-backed hooks tried to start Docker; the non-Docker socket cases passed, then the run failed because Docker is not running locally (~/.docker/run/docker.sockmissing).Note
Low Risk
Type-level widening plus internal factory narrowing; TLS is still only used when
tls === true, with no change to connection security behavior.Overview
Fixes compile-time rejection of
socket.tlswhen it is a runtimeboolean(e.g. Heroku-styletls: redisUrl.match(/rediss:/) != null), by wideningRedisTlsOptions.tlsfrom the literaltruetoboolean.Runtime behavior is unchanged:
RedisSocketstill opens a TLS connection only whenoptions?.tls === true;falsecontinues to use plain TCP/IPC. IPC and TCP branches in#createSocketFactorynow narrow options with explicit casts so spreading defaults stays type-safe.A compile-time regression in
create-client.types-test.tslocks in the Heroku-stylecreateClientconfiguration.Reviewed by Cursor Bugbot for commit 6bdb254. Bugbot is set up for automated code reviews on this repo. Configure here.