-
Notifications
You must be signed in to change notification settings - Fork 337
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
Issue with reset! method and MemoryStore Cache #672
Comments
Hi, what version of it 'should delete rack attack keys' do
memory_store = ActiveSupport::Cache::MemoryStore.new
memory_store.write('key', 'value')
memory_store.write("#{Rack::Attack.cache.prefix}::key", 'value')
Rack::Attack.cache.store = memory_store
Rack::Attack.reset!
_(memory_store.read('key')).must_equal 'value'
_(memory_store.read("#{Rack::Attack.cache.prefix}::key")).must_be_nil
end but it worked just fine. Looking https://github.com/rails/rails/blob/main/activesupport/lib/active_support/cache/memory_store.rb#L173 and https://github.com/rails/rails/blob/main/activesupport/lib/active_support/cache.rb#L779 I don't think Would you mind providing a reproduction script or more detailed steps to reproduce? Thanks |
Thanks for looking. Indeed in our case namespace is set! Apologies for leaving out that detail. |
Cool. And how is that possible? Are you monkey-patching |
Namespace is a Rails cache store argument. The namespace is setting the scope of the cache basically. |
Gotcha, thanks for the clarification. I opened #673 to address this issue. |
rack-attack/lib/rack/attack/cache.rb
Lines 56 to 59 in 0d40ea6
This code calls
delete_matched
and passes in a string. However, MemoryStore for Rails.cache requires it to be a Regex.When calling the
reset!
method with Rails.cache set to MemoryStore, you will be greeted with this error:The text was updated successfully, but these errors were encountered: