-
Notifications
You must be signed in to change notification settings - Fork 0
chore: downgrade redis to 5.4.1 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Euler-B/Telurify-API
Length of output: 228
🌐 Web query:
Rails 7.2.3 ActiveSupport::Cache::RedisCacheStore error_handler redis with ping source💡 Result:
In Rails 7.2.3, the ActiveSupport::Cache::RedisCacheStore uses a default error handler defined as DEFAULT_ERROR_HANDLER [1][2]. This handler is responsible for logging errors via the Rails logger and reporting them to the ActiveSupport error reporter with the source "redis_cache_store.active_support" [1][2]. The default error handler is defined as: DEFAULT_ERROR_HANDLER = -> (method:, returning:, exception:) do if logger logger.error { "RedisCacheStore: #{method} failed, returned #{returning.inspect}: #{exception.class}: #{exception.message}" } end ActiveSupport.error_reporter&.report( exception, severity::warning, source: "redis_cache_store.active_support",) end The RedisCacheStore internal implementation includes a failsafe method that wraps cache operations and calls this
@error_handlerif a Redis::BaseError, ConnectionPool::Error, or ConnectionPool::TimeoutError occurs [2]. Regarding your mention of "ping": ActiveSupport::Cache::RedisCacheStore does not include a specific "ping" option or native mechanism within its error handler configuration to automatically ping Redis upon an error [1][2]. If you need to perform health checks or pings, you would typically implement that logic within a custom error handler provided to the RedisCacheStore during initialization [1][2]. You can override the default behavior by passing a custom error_handler proc when creating your RedisCacheStore instance: # Example of providing a custom error handler config.cache_store =:redis_cache_store, { error_handler: -> (method:, returning:, exception:) do # Add your custom logic here, such as logging, metrics, or pinging Redis Rails.logger.error("Redis error in #{method}: #{exception.message}") end } If you are encountering specific errors, ensure they are among those caught by the store's internal failsafe mechanism (Redis::BaseError, ConnectionPool::Error, or ConnectionPool::TimeoutError) [2].Citations:
🌐 Web query:
Rack::Attack cache store increment nil behavior source💡 Result:
In Rack::Attack, the cache store's
incrementmethod is handled with a fallback mechanism to accommodate differences in how various cache stores (such as Redis or Memcached) behave when incrementing a key that does not yet exist [1][2]. The relevant logic is located in theRack::Attack::Cache#do_countmethod within thelib/rack/attack/cache.rbsource file [1][2]. WhenRack::Attackattempts to increment a counter, it callsstore.incrementand checks the result [1][2]: 1. Detection of Nil: Some cache stores returnnilwhen an attempt is made to increment a key that has not been initialized [1][2]. 2. Fallback Logic: If theresultof theincrementcall isnil,Rack::Attackimmediately executesstore.write(key, 1, expires_in: expires_in)to manually initialize the key with a value of 1 [1][2]. 3. Return Value: The method ultimately returnsresult || 1, ensuring that the application receives a valid integer (typically 1 for a new entry) even if the underlying store returnednil[1][2]. This implementation is designed to handle potential inconsistencies across differentActiveSupport::Cachestores, ensuring that rate limiting counters remain accurate even when the cache backend does not support atomic "increment-or-initialize" behavior [1][2].Citations:
🏁 Script executed:
Repository: Euler-B/Telurify-API
Length of output: 2470
Rate-limit Failure-open (CWE-799)
Reachability: External · Exploitability: Moderate
Make Redis failure handling fail closed for rate limiting.
MemoryStoreis process-local, so clustered Puma workers do not share fallback counters. Later Redis failures also returnnil; Rack Attack converts that result to count1, which disables throttling.Use
MemoryStoreonly outside production, probe Redis during initialization, and raise on production cache errors:🤖 Prompt for AI Agents
Source: Path instructions