GithubHelp home page GithubHelp logo

tylerrick / rack_attack_admin Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 8.0 166 KB

A Rack::Attack admin dashboard

License: MIT License

Ruby 83.13% HTML 16.32% Shell 0.55%
rack-attack rack-middleware rack ruby rails admin-dashboard administration dashboard admin

rack_attack_admin's Introduction

Rack::Attack Admin Dashboard Gem Version

Lets you see the current state of all throttles and bans. Delete existing keys/bans. Manually add bans.

Screenshot

Inspired by: https://www.backerkit.com/blog/building-a-rackattack-dashboard/

Installation

Add this line to your application's Gemfile:

gem 'rack_attack_admin'

Add this line to your application's config/routes.rb:

mount RackAttackAdmin::Engine, at: '/admin/rack_attack'

Usage

Go to http://localhost:3000/admin/rack_attack in your browser!

You can also use the provided read-only command-line command, rake rack_attack_admin:watch instead of the web interface:

+-------------------------------+--------------------+
| Banned IP                     | Previous (5 s ago) |
+-------------------------------+--------------------+
| allow2ban:ban:login-127.0.0.1 |                    |
+-------------------------------+--------------------+
+----------------------------------------------------------------------------------+---------------+--------------------+
| Key                                                                              | Current Count | Previous (5 s ago) |
+----------------------------------------------------------------------------------+---------------+--------------------+
| ('allow2ban:count'):login-127.0.0.1                                              | 2             | 1                  |
| throttle('logins/ip'):127.0.0.1                                                  | 1             |                    |
| throttle('logins/email'):[email protected]                                          | 1             |                    |
| throttle('req/ip'):127.0.0.1                                                     | 2             | 1                  |
+----------------------------------------------------------------------------------+---------------+--------------------+

Fail2Ban/Allow2Ban

In order to allow your Fail2Ban/Allow2Ban rules to be introspected by this app, you must define them slightly differently than the upstream Rack::Attack documentation tells you to define them:

If you have an Allow2Ban filter in a blocklist like this:

  blocklist('login:allow2ban') do |req|
    Rack::Attack::Allow2Ban.filter("login-#{req.ip}", maxretry: 5, findtime: 1.minute, bantime: 10.minutes) do
      # The count for the IP is incremented if this return value is truthy.
      is_login.(req)
    end
  end

, you can change it to this equivalent definition:

  blocklist('login:allow2ban') do |req|
    def_allow2ban('login', limit: 5, period: 1.minute, bantime: 10.minutes)
    allow2ban(    'login', req.ip) do
      is_login.(req)
    end
  end

def_fail2ban/def_allow2ban save your configuration in a hash (by name, without discriminator in it), much the same as throttle does.

fail2ban/allow2ban methods are simply wrappers for Rack::Attack::Allow2Ban.filter that look up and use the options from the definition (that matches the given name).

This has the following advantages:

  • It actually stores your Fail2Ban rule so that we can look it up later
  • It provides an API and options that are more similar to and consistent with regular throttle commands:
    # Compare:
    def_allow2ban('login', limit: 5, period: 1.minute, bantime: )
    allow2ban('login', discriminator) do
      # Return truthy value to increment counter
    end
    # allow2ban returns true if counter reaches limit
    
    throttle('logins/email', limit: 5, period: 1.minute) do |req|
      discriminator.(req)
    end
  • You can use the familiar limit and period options instead of maxretry and findtime options, respectively.
  • You don't have to interpolate the discriminator into a string like you do with the standard Fail2Ban.filter syntax.

This is completely optional. If you choose not to define them this way, it will still show your fail2ban counter keys and value; it just won't be able to find the matching rule, and therefore won't be able to show what the limit or time bucket is for that counter key. So instead of showing the limit for allow2ban('login') like it shows in the screenshot above, it will fall back to just showing what little it can show about that key:

Screenshot

Redis cache store compatibility

This has been tested with Rack::Attack.cache.store set to an instance of:

  • Redis::Store from the fantastic redis-store gem. (Which is used by the ActiveSupport::Cache::RedisStore (from redis-activesupport/redis-rails gems))
  • ActiveSupport::Cache::RedisCacheStore (provided by Rails 5.2+)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/TylerRick/rack_attack_admin.

rack_attack_admin's People

Contributors

tylerrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rack_attack_admin's Issues

undefined method `keys' for #<ActiveSupport::Cache::FileStore:0x0000560ca1d37ad0>

Doesn't seem to work ...

Traceback

NoMethodError: undefined method `keys' for #<ActiveSupport::Cache::FileStore:0x0000560ca1d37ad0>
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack_attack_admin-0.1.2/lib/rack/attack_extensions.rb", line 11, in all_keys
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack_attack_admin-0.1.2/lib/rack/attack_extensions.rb", line 67, in prefixed_keys
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack_attack_admin-0.1.2/lib/rack/attack_extensions.rb", line 72, in keys
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack_attack_admin-0.1.2/lib/rack/attack_extensions.rb", line 88, in counters_h
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack_attack_admin-0.1.2/app/controllers/rack_attack_admin/rack_attack_controller.rb", line 8, in index
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/basic_implicit_render.rb", line 6, in send_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/base.rb", line 194, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/rendering.rb", line 30, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/callbacks.rb", line 42, in block in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb", line 109, in block in run_callbacks
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/ahoy_matey-3.0.1/lib/ahoy/controller.rb", line 45, in set_ahoy_request_store
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb", line 118, in block in run_callbacks
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/audited-4.8.0/lib/audited/sweeper.rb", line 14, in around
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb", line 118, in block in run_callbacks
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/audited-4.8.0/lib/audited/sweeper.rb", line 14, in around
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb", line 118, in block in run_callbacks
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb", line 136, in run_callbacks
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/callbacks.rb", line 41, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/rescue.rb", line 22, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb", line 34, in block in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb", line 168, in block in instrument
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb", line 23, in instrument
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb", line 168, in instrument
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb", line 32, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/params_wrapper.rb", line 256, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/searchkick-4.1.0/lib/searchkick/logging.rb", line 211, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/railties/controller_runtime.rb", line 24, in process_action
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/base.rb", line 134, in process
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/rendering.rb", line 32, in process
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal.rb", line 191, in dispatch
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal.rb", line 252, in dispatch
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb", line 52, in dispatch
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb", line 34, in serve
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb", line 52, in block in serve
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb", line 35, in each
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb", line 35, in serve
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb", line 840, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/action_dispatch/routing/route_set.rb", line 14, in block in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/fanout.rb", line 25, in instrument
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/action_dispatch/routing/route_set.rb", line 13, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb", line 524, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/railtie.rb", line 190, in public_send
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/railtie.rb", line 190, in method_missing
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/mapper.rb", line 19, in block in <class:Constraints>
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/mapper.rb", line 48, in serve
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb", line 52, in block in serve
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb", line 35, in each
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb", line 35, in serve
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb", line 840, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/action_dispatch/routing/route_set.rb", line 14, in block in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/fanout.rb", line 25, in instrument
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/action_dispatch/routing/route_set.rb", line 13, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rollbar-2.16.4/lib/rollbar/middleware/js.rb", line 25, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-attack-6.2.2/lib/rack/attack.rb", line 170, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb", line 36, in block in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb", line 34, in catch
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/tempfile_reaper.rb", line 17, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/etag.rb", line 27, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/conditional_get.rb", line 27, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/head.rb", line 14, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/http/content_security_policy.rb", line 18, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/session/abstract/id.rb", line 277, in context
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/session/abstract/id.rb", line 271, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/cookies.rb", line 670, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb", line 28, in block in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb", line 98, in run_callbacks
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb", line 26, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rollbar-2.16.4/lib/rollbar/middleware/rails/rollbar.rb", line 24, in block in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rollbar-2.16.4/lib/rollbar.rb", line 146, in scoped
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rollbar-2.16.4/lib/rollbar/middleware/rails/rollbar.rb", line 22, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/debug_exceptions.rb", line 61, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rollbar-2.16.4/lib/rollbar/middleware/rails/show_exceptions.rb", line 22, in call_with_rollbar
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/show_exceptions.rb", line 33, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/rack/logger.rb", line 38, in call_app
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/rack/logger.rb", line 26, in block in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb", line 71, in block in tagged
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb", line 28, in tagged
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb", line 71, in tagged
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/rack/logger.rb", line 26, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/ahoy_matey-3.0.1/lib/ahoy/engine.rb", line 22, in call_with_quiet_ahoy
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb", line 81, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb", line 27, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/action_dispatch/request_id.rb", line 12, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/method_override.rb", line 24, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/runtime.rb", line 24, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb", line 29, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb", line 14, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb", line 127, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/sendfile.rb", line 113, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/ssl.rb", line 74, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/probes/middleware.rb", line 34, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/skylight-core-4.2.0/lib/skylight/core/middleware.rb", line 84, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb", line 524, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/configuration.rb", line 228, in call
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/server.rb", line 681, in handle_request
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/server.rb", line 472, in process_client
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/server.rb", line 328, in block in run
  File "/home/deploy/apps/immersive/shared/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/thread_pool.rb", line 134, in block in spawn_thread

Doesn't work in Rails 4.2: LoadError: cannot load such file -- active_support/duration/iso8601_serializer

Fails during bundling phase:

	 9: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/rack_attack_admin-0.1.2/lib/rack_attack_admin.rb:3:in `<top (required)>'
	 8: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
	 7: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
	 6: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `block in require'
	 5: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
	 4: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-duration-human_string-0.1.1/lib/active_support/duration/human_string.rb:2:in `<top (required)>'
	 3: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
	 2: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
	 1: from /Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `block in require'
/Users/nowaker/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- active_support/duration/iso8601_serializer (LoadError)

As per https://apidock.com/rails/ActiveSupport/Duration/ISO8601Serializer, this class was introduced in Rails 5. The gemspec itself depends on Rails >= 4.2.

New syntax for blocklists doesn't work: undefined method `limit' for #<Rack::Attack::Blocklist:0x000055c369b07340>

Original blocklist definition:

Rack::Attack.blocklist('bot_php') do |req|
  Rack::Attack::Allow2Ban.filter(req.ip, maxretry: 5, findtime: 1.minute, bantime: 1.hour) do
    next unless req.path.end_with?('.php') || req.path.include?('wp-admin')
    req.ip
  end

New blocklist definition:

Rack::Attack.blocklist('bot_php') do |req|
  Rack::Attack.def_allow2ban('bot_php', limit: 5, period: 1.minute, bantime: 1.hour)
  Rack::Attack.allow2ban('bot_php', req.ip) do
    next unless req.path.end_with?('.php') || req.path.include?('wp-admin')
    req.ip
  end
end

Result when visiting the admin dashboard:

Showing /home/nowaker/projekty/modern/rack_attack_admin/app/views/rack_attack_admin/rack_attack/index.html.haml where line #80 raised:

undefined method `limit' for #<Rack::Attack::Blocklist:0x000055c369b07340>

Broken HAML line:

      - limit = parsed && (rule = parsed[:rule]) && rule.limit.to_i

It suggests Rack::Attack::Fail2Ban is not InstantiableFail2Ban. Why? No idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.