feat: refine Top Attackers & Banned IPs - #8
Merged
Conversation
…anned IPs - attackers: extract attempt_counts() + parse_attackers(exclude=...) to drop already-banned IPs before ranking - dashboard: top_attackers() excludes currently-banned IPs; banned_ips() attaches per-IP failed-attempt counts (best-effort, never fatal) - models: BannedIP gains a count field - banned view: new sortable Attempts column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small UX refinements requested for the fail2ban panels:
focuses on active threats still worth acting on.
count from the auth log.
Changes
services/attackers.py: split out pureattempt_counts();parse_attackers()takes an
excludeset so banned IPs are dropped before top-N ranking.services/dashboard.py:top_attackers()excludes currently-banned IPs;banned_ips()attaches attempt counts. Both lookups are best-effort — a missingauth log or fail2ban never breaks the panel.
models.py:BannedIPgains acountfield (default 0).views/banned.html: new sortable Attempts column (—when unknown).Test plan
attempt_countsreturns the full mapping;excludedrops IPs pre-ranking.Summary by cubic
Top Attackers now hides already-banned IPs, and Banned IPs shows an Attempts count from the auth log. This focuses the dashboard on active threats and adds useful context.
Written for commit df32965. Summary will update on new commits.