Add Bot Activity admin panel: banned-IP view + recent events + emergency unban #23

Merged
whitlocktech merged 1 commits from feature/bot-activity-admin into main 2026-07-03 08:29:56 +00:00
Member

Summary

Adds a new admin-only Bot Activity tab exposing the botScore middleware's scoring/ban state. Previously that state lived only in the in-memory store Map with no API or persistence � the only visibility was tailing container logs.

Changes

Server

  • botScore.js: bounded (300-entry) most-recent-first ring buffer recording scan / login-fail / honeypot events plus a distinct ban event when a hit crosses the threshold. Adds recentEvents(), listState() (per-IP score/banned/bannedUntil/lastSeen), and unban(ip).
  • New botActivity.controller.js + routes GET /admin/bot-activity and POST /admin/bot-activity/unban, both behind the existing requireRole('admin') RBAC gate; IP validated with isIP(). Unban is activity-logged with the admin username (action: botscore.unban).

Client

  • api.admin.botActivity() / unbanIp().
  • New BotActivityAdmin.jsx view: a currently-banned table (IP / score / banned until / Unban) and a recent-events feed (when / IP / reason / path / points / score), following the existing useAsync + adm-table / panel-flat patterns.
  • Registered tab in AdminLayout + route in App.jsx.

Tests & docs

  • 5 new botScore.test.js cases (buffer ordering + ban event, buffer cap, listState, unban clears/lifts a ban, guard lets an unbanned IP through). All 45 server tests pass; client build is clean.
  • README updated (routes, API, security, structure).

Scope

Read + emergency-unban only � no ban-add or scoring-weight editing from the UI. Buffer is in-memory (matches the store); not persisted to the DB. Admin-only via existing RBAC.

Verification

  • npm test (server): 45/45 pass.
  • npm run build (client): clean; dev preview mounts with no console errors, /admin/bot-activity correctly redirects to the login gate.
  • Not yet exercised live behind auth (needs the API server + DB + admin login).

?? Generated with Claude Code

## Summary Adds a new admin-only **Bot Activity** tab exposing the `botScore` middleware's scoring/ban state. Previously that state lived only in the in-memory `store` Map with no API or persistence � the only visibility was tailing container logs. ## Changes **Server** - `botScore.js`: bounded (300-entry) most-recent-first ring buffer recording `scan` / `login-fail` / `honeypot` events plus a distinct `ban` event when a hit crosses the threshold. Adds `recentEvents()`, `listState()` (per-IP score/banned/bannedUntil/lastSeen), and `unban(ip)`. - New `botActivity.controller.js` + routes `GET /admin/bot-activity` and `POST /admin/bot-activity/unban`, both behind the existing `requireRole('admin')` RBAC gate; IP validated with `isIP()`. Unban is activity-logged with the admin username (`action: botscore.unban`). **Client** - `api.admin.botActivity()` / `unbanIp()`. - New `BotActivityAdmin.jsx` view: a currently-banned table (IP / score / banned until / Unban) and a recent-events feed (when / IP / reason / path / points / score), following the existing `useAsync` + `adm-table` / `panel-flat` patterns. - Registered tab in `AdminLayout` + route in `App.jsx`. **Tests & docs** - 5 new `botScore.test.js` cases (buffer ordering + ban event, buffer cap, `listState`, `unban` clears/lifts a ban, guard lets an unbanned IP through). All 45 server tests pass; client build is clean. - README updated (routes, API, security, structure). ## Scope Read + emergency-unban only � no ban-add or scoring-weight editing from the UI. Buffer is in-memory (matches the store); not persisted to the DB. Admin-only via existing RBAC. ## Verification - `npm test` (server): 45/45 pass. - `npm run build` (client): clean; dev preview mounts with no console errors, `/admin/bot-activity` correctly redirects to the login gate. - Not yet exercised live behind auth (needs the API server + DB + admin login). ?? Generated with [Claude Code](https://claude.com/claude-code)
wtclaude added 1 commit 2026-07-03 07:32:03 +00:00
Expose the botScore middleware's in-memory scoring/ban state to admins.
Previously state lived only in the store Map with no persistence or API — the
only visibility was tailing container logs.

- botScore: bounded ring buffer (300) recording scan/login-fail/honeypot and
  ban events (most-recent-first); listState() snapshot of all scored IPs;
  unban() to clear a single IP.
- New admin-only endpoints GET /admin/bot-activity and
  POST /admin/bot-activity/unban (RBAC admin gate, IP validated). Unban is
  activity-logged with the admin username.
- Bot Activity tab: currently-banned table with Unban, plus a recent-events
  feed, following the existing admin table patterns.
- Tests for the buffer, listState, and unban (guard lets an unbanned IP back
  through). README updated.

Read + emergency-unban only — no ban-add or weight-editing surface. Buffer is
in-memory, matching the store; not persisted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
whitlocktech approved these changes 2026-07-03 08:26:12 +00:00
whitlocktech merged commit 8fa34ca68e into main 2026-07-03 08:29:56 +00:00
whitlocktech deleted branch feature/bot-activity-admin 2026-07-03 08:29:57 +00:00
Sign in to join this conversation.
No description provided.