feat: coordinated bot pattern blacklist (BotPattern) #81

Open
opened 2026-11-22 22:59:27 +01:00 by mistral · 0 comments
Collaborator

Summary

Bot filtering is scattered: Ahoy's default bot exclusion misses headless
datacenter bots, and the BannedIp/BanCheck edge blocking uses its own
list. This feature introduces a single admin-editable BotPattern
blacklist (IP prefixes + user-agent patterns) with one shared matcher used
by both Ahoy (dismiss visits at ingest) and BanCheck (403 at the edge),
plus a "Ban Bots" admin UI and seeded defaults.

PRD

📄 docs/prd/0002-bot-pattern-blacklist.md

Acceptance criteria

  • BotPattern model (kind: ip_prefix|user_agent, value, active) with migration and seeds
  • BotPattern.matches?(ip:, user_agent:) shared matcher with unit tests
  • Ahoy::Store#bot? uses the matcher; hardcoded lists removed
  • BanCheck rejects requests whose IP matches an active pattern
  • Admin CRUD UI under a "Ban Bots" menu entry
  • One-off task purges existing Ahoy::Visit records matching active patterns

Tasks

  • Create bot_patterns migration + BotPattern model with validations
  • Implement BotPattern.matches? and unit tests
  • Seed default datacenter/UA patterns
  • Rewire Ahoy::Store#bot? to the shared matcher + tests
  • Rewire BanCheck to also check IP patterns + tests
  • Build admin "Ban Bots" CRUD UI
  • Add one-off purge task for existing matching visits
  • Run test suite and RuboCop in the container

Technical notes

Out of scope: recurring auto-ban scan job (follow-up), DNS-verified
crawler bypass, country/asn pattern kinds. BotPattern includes Auditable.

## Summary Bot filtering is scattered: Ahoy's default bot exclusion misses headless datacenter bots, and the BannedIp/BanCheck edge blocking uses its own list. This feature introduces a single admin-editable `BotPattern` blacklist (IP prefixes + user-agent patterns) with one shared matcher used by both Ahoy (dismiss visits at ingest) and BanCheck (403 at the edge), plus a "Ban Bots" admin UI and seeded defaults. ## PRD 📄 docs/prd/0002-bot-pattern-blacklist.md ## Acceptance criteria - [ ] BotPattern model (kind: ip_prefix|user_agent, value, active) with migration and seeds - [ ] BotPattern.matches?(ip:, user_agent:) shared matcher with unit tests - [ ] Ahoy::Store#bot? uses the matcher; hardcoded lists removed - [ ] BanCheck rejects requests whose IP matches an active pattern - [ ] Admin CRUD UI under a "Ban Bots" menu entry - [ ] One-off task purges existing Ahoy::Visit records matching active patterns ## Tasks - [ ] Create bot_patterns migration + BotPattern model with validations - [ ] Implement BotPattern.matches? and unit tests - [ ] Seed default datacenter/UA patterns - [ ] Rewire Ahoy::Store#bot? to the shared matcher + tests - [ ] Rewire BanCheck to also check IP patterns + tests - [ ] Build admin "Ban Bots" CRUD UI - [ ] Add one-off purge task for existing matching visits - [ ] Run test suite and RuboCop in the container ## Technical notes Out of scope: recurring auto-ban scan job (follow-up), DNS-verified crawler bypass, country/asn pattern kinds. BotPattern includes Auditable.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
as-consult/starterkit-8#81
No description provided.