Fix Fail2Ban and Allow2Ban not banning with dalli 4 and 5 - #721
Draft
santib wants to merge 2 commits into
Draft
Conversation
added 2 commits
September 8, 2026 14:26
Dalli 4 and 5 are the current major versions and the suite only ran against dalli 3. Add appraisals and gemfiles for both, and exclude the Ruby versions each one does not support (dalli 4 requires Ruby >= 3.1, dalli 5 requires Ruby >= 3.3).
Dalli 4 and 5 raise Dalli::MarshalError when a raw set receives a non-String value, while Dalli 3 converted it with to_s. DalliProxy rescues DalliError and returns nil, so Fail2Ban and Allow2Ban never wrote their ban key and never banned.
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.
Problem
With dalli 4 and 5,
Fail2BanandAllow2Bannever ban when the store is aDalli::Client(directly or through aConnectionPool).Fail2Ban#ban!writes the Integer1, andDalliProxy#writepasses it toclient.set(..., raw: true). Dalli 3 converted it withto_s; dalli 4 and 5 raise instead:DalliProxyrescuesDalli::DalliErrorand returnsnil, so the ban key is never written andbanned?is alwaysfalse. Throttling is not affected because it uses memcached'sincr, which does not go through the serializer.Fix
Call
value.to_sbefore the rawsetinDalliProxy#write. Same behavior as dalli 3 did internally.Verification
Adds dalli 4 and dalli 5 to the CI matrix (appraisals and gemfiles, excluding the Ruby versions each one does not support: dalli 4 requires Ruby >= 3.1, dalli 5 requires Ruby >= 3.3). Without the fix,
works for fail2banandworks for allow2baninspec/acceptance/stores/dalli_client_spec.rbfail on every dalli 4/5 job (expected 403, got 200).