Skip to content

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

@Nowaker

Description

@Nowaker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions