1
0
mirror of https://github.com/redis/go-redis.git synced 2025-09-05 20:24:00 +03:00
Commit Graph

15 Commits

Author SHA1 Message Date
ofekshenawa
8ff9a76346 fix: update cluster test expectations for TLS 1.2 enforcement
Fix the failing cluster test 'ClusterClient ParseURL match ParseClusterURL'
by updating the MissingRedissPort test case to expect MinVersion: tls.VersionTLS12.

The test was failing because:
- Expected: MinVersion: 0 (not set)
- Actual: MinVersion: 771 (TLS 1.2)

This aligns with our security-first approach where all rediss:// URLs
automatically enforce TLS 1.2 minimum, even when no TLS parameters
are explicitly specified.

Test verification:
- Created and ran isolated test confirming ParseClusterURL now correctly
  sets MinVersion: 771 for basic rediss://localhost URLs
- All cluster URL parsing now consistent with single client behavior

This resolves the cluster test failure while maintaining the enhanced
security posture across all client types.
2025-08-14 18:46:09 +03:00
ofekshenawa
62a56aa6b1 fix: update test expectations for consistent TLS 1.2 enforcement
After pulling the latest security fixes, update test cases to match the new
security-first behavior where all rediss:// URLs enforce TLS 1.2 minimum:

**Changes Made**:
1. **Cluster Test Fixes**:
   - Updated ParseRedissURL test to expect MinVersion: tls.VersionTLS12
   - Updated MultipleRedissURLs test to expect MinVersion: tls.VersionTLS12
   - Updated RedissTLSCert test to expect MinVersion: tls.VersionTLS12
   - Updated RedissSkipVerify test to expect MinVersion: tls.VersionTLS12

2. **Sentinel Client Consistency**:
   - Made sentinel client behavior consistent with single/cluster clients
   - Always set MinVersion to TLS 1.2 for rediss:// URLs, even when not specified
   - Matches the security-first approach across all client types

**Security Behavior**:
- All rediss:// URLs now enforce minimum TLS 1.2 by default
- Consistent security posture across single, cluster, and sentinel clients
- No breaking changes for secure configurations
- Enhanced security for all TLS connections

**Test Results**:
- All single client tests pass 
- All builds successful 
- Consistent behavior across all client types 

This ensures uniform security enforcement and test expectations across
the entire go-redis library.
2025-08-14 17:13:13 +03:00
ofekshenawa
85cfa2db7b security: fix CodeQL security vulnerabilities in TLS parameters
Address 9 high-severity security issues identified by GitHub CodeQL:

1. **Integer Conversion Security**:
   - Add proper bounds checking for tls_min_version and tls_max_version
   - Validate input range (0-65535) before casting to uint16
   - Prevent integer overflow vulnerabilities

2. **TLS Security Enforcement**:
   - Enforce minimum TLS 1.2 (771) for all TLS version parameters
   - Reject insecure TLS versions (< TLS 1.2) with clear error messages
   - Prevent downgrade attacks and insecure configurations

3. **Comprehensive Validation**:
   - Applied security fixes to all client types (single, cluster, sentinel)
   - Added security validation test cases
   - Updated documentation to reflect security requirements

4. **Test Coverage**:
   - Added tests for insecure TLS version rejection
   - Added tests for integer overflow protection
   - Updated existing tests to use secure TLS versions (771, 772)

Security improvements:
- Prevents integer overflow attacks via malicious URL parameters
- Enforces secure TLS configurations by default
- Provides clear error messages for security violations
- Maintains backward compatibility for secure configurations

Fixes all CodeQL security alerts while maintaining functionality.
2025-08-14 11:10:31 +03:00
ofekshenawa
8c5764632d feat: extend TLS URL parameters to all client types
Add comprehensive TLS URL parameter support across all Redis client types:

- Cluster Client (ParseClusterURL): Full TLS parameter support
- Sentinel Client (ParseFailoverURL): Full TLS parameter support
- Universal Client: Inherits support from underlying clients

Supported parameters for all client types:
- tls_cert_file and tls_key_file: Client certificate authentication
- tls_min_version and tls_max_version: TLS version constraints
- tls_server_name: Server name override for certificate validation
- skip_verify: Skip certificate verification (existing parameter)

Features:
- Consistent API across all client types
- Comprehensive test coverage for cluster client
- Enhanced documentation for all client configurations
- Proper error handling and validation

This ensures users have the same TLS configuration capabilities
regardless of which Redis client type they use, providing a
consistent and complete TLS configuration experience.
2025-08-14 11:01:41 +03:00
ofekshenawa
436979f5c7 feat(options): Clean failing timeout implementation (#3472)
* Fix hard code of failing timeout

1. if not set failing time limit, default is 15 seconds.

* feat: Complete configurable FailingTimeoutSeconds implementation

---------

Co-authored-by: Shino Wu <shino_wu@trendmicro.com>
2025-08-12 14:08:28 +03:00
Nedyalko Dyakov
05f42e2327 fix(txpipeline): keyless commands should take the slot of the keyed (#3411)
* fix(txpipeline): keyless commands should take the slot of the keyed commands

* fix(txpipeline): extract only keyed cmds from all cmds

* chore(test): Add tests for keyless cmds and txpipeline

* fix(cmdSlot): Add preferred random slot

* fix(cmdSlot): Add shortlist of keyless cmds

* chore(test): Fix ring test

* fix(keylessCommands): Add list of keyless commands

Add list of keyless Commands based on the Commands output
for redis 8

* chore(txPipeline): refactor slottedCommands impl

* fix(osscluster): typo
2025-06-24 10:34:23 +03:00
Nedyalko Dyakov
4c635cc563 fix(txpipeline): should return error on multi/exec on multiple slots [CAE-1028] (#3408)
* fix(txpipeline): should return error on multi/exec on multiple slots

* fix(txpipeline): test normal tx pipeline behaviour

* chore(err): Extract crossslot err and add test

* fix(txpipeline): short curcuit the tx if there are no commands

* chore(tests): validate keys are in different slots
2025-06-18 14:18:00 +03:00
cxljs
82b00cc520 chore: remove a redundant method (#3401)
Signed-off-by: fukua95 <fukua95@gmail.com>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
2025-06-16 16:55:23 +03:00
Nedyalko Dyakov
86d418f940 feat: Introducing StreamingCredentialsProvider for token based authentication (#3320)
* wip

* update documentation

* add streamingcredentialsprovider in options

* fix: put back option in pool creation

* add package level comment

* Initial re authentication implementation

Introduces the StreamingCredentialsProvider as the CredentialsProvider
with the highest priority.

TODO: needs to be tested

* Change function type name

Change CancelProviderFunc to UnsubscribeFunc

* add tests

* fix race in tests

* fix example tests

* wip, hooks refactor

* fix build

* update README.md

* update wordlist

* update README.md

* refactor(auth): early returns in cred listener

* fix(doctest): simulate some delay

* feat(conn): add close hook on conn

* fix(tests): simulate start/stop in mock credentials provider

* fix(auth): don't double close the conn

* docs(README): mark streaming credentials provider as experimental

* fix(auth): streamline auth err proccess

* fix(auth): check err on close conn

* chore(entraid): use the repo under redis org
2025-05-27 16:25:20 +03:00
Bhargav Dodla
162a15432b fix: Fixed issue with context cancelled error leading to connection spikes on Primary instances (#3190)
* fix: Fixed issue with context cancelled error leading to connection spikes on Master

* fix: Added tests

* fix: Updated tests

---------

Co-authored-by: Bhargav Dodla <bdodla@expediagroup.com>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
2025-03-05 22:08:27 +02:00
Nedyalko Dyakov
ebe11d06ca feat: Enable CI for Redis CE 8.0 (#3274)
* chore: extract benchmark tests

* wip

* enable pubsub tests

* enable ring tests

* stop tests with build redis from source

* start all tests

* mix of makefile and action

* add sentinel configs

* fix example test

* stop debug on re

* wip

* enable gears for redis 7.2

* wip

* enable sentinel, they are expected to fail

* fix: linter configuration

* chore: update re versions

* return older redis enterprise version

* add basic codeql

* wip: increase timeout, focus only sentinel tests

* sentinels with docker network host

* enable all tests

* fix flanky test

* enable example tests

* tidy docker compose

* add debug output

* stop shutingdown masters

* don't test sentinel for re

* skip unsuported addscores

* Update README

bump go version in CI

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update CONTRIBUTING.md

add information about new test setup

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-02-28 12:49:00 +02:00
Nedyalko Dyakov
1139bc3aa9 fix(tests): enable testing with Redis CE 8.0-M4 in CI (#3247)
* introduce github workflow for ci similar to the one in redis-py

use prerelease for 8.0-M4

* Enable osscluster tests in CI

* Add redis major version env

Enable filtering test per redis major version
Fix test for FT.SEARCH WITHSCORE, the default scorer
has changed.

fix Makefile syntax

remove filter from github action

fix makefile

use the container name in Makefile

* remove 1.20 from doctests

* self review, cleanup, add comments

* add comments, reorder prints, add default value for REDIS_MAJOR_VERSION
2025-01-31 16:14:11 +02:00
LINKIWI
fc32d0a01d Recognize byte slice for key argument in cluster client hash slot computation (#3049)
Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2024-11-21 14:38:11 +02:00
LINKIWI
5756b05219 Avoid unnecessary retry delay following MOVED and ASK redirection (#3048) 2024-07-13 14:55:12 +08:00
Chayim
6199a2af2c Making command structs digestable (#2716)
* intial move

* adding stringcmdable

* moving module commands to align with other changes

---------

Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
Co-authored-by: ofekshenawa <ofek.shenawa@redis.com>
2023-09-20 16:08:24 +03:00