fix(client): accept boolean TLS socket options#3307
Open
puneetdixit200 wants to merge 1 commit into
Open
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. |
Collaborator
|
Thanks @puneetdixit200, i will have a look. |
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.
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.