Repository navigation
loghunt 0.2.0: fit your server (--allow, thresholds, --since/--until, --blocklist-format) - #1
Merged
Merged
Conversation
A published release builds the sdist and wheel, checks them with `twine check --strict`, verifies the tag matches the package version, smoke-tests the wheel on the bundled sample, then uploads with Trusted Publishing (OIDC) from the `pypi` environment. No token is stored. Every action is pinned to a commit SHA. The version now lives only in src/loghunt/__init__.py. The README uses absolute image and license URLs so they render on PyPI, installs from PyPI, and shows a PyPI badge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Five releases from "find attackers in a log you have" to "watch a log as it grows": fit your server (0.2), read more log formats (0.3), catch botnets that rotate User-Agents (0.4), and a --follow mode (0.5). Also lists what is not planned and why: blocking by itself, network lookups during analysis, and scores that cannot explain themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--allow takes an IP, a CIDR range or @file with one entry per line (# starts a comment) and can be repeated. Allowed IPs still count toward traffic totals, but are never flagged, never grouped into a campaign and never written to the blocklist, so three uptime monitors running the same login check cannot become a "botnet". An IPv4 client logged as ::ffff:203.0.113.9 by a dual-stack socket matches the IPv4 range. A bad entry stops the run with exit status 2 and names the file and line. The terminal summary, the JSON ("allowed") and the HTML footer say how many IPs were skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The defaults suit a small-to-medium site; a busy shop or a WordPress
site with many real logins needs higher numbers. Campaigns use the same
login and probe numbers for their group totals.
--flood below --burst is rejected, because the flood check runs first
and would hide every burst. The JSON output now records the thresholds
a run used ("thresholds"); the HTML footer already did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Accepts 2026-10-20, 2026-10-20 08:30 and 2026-10-20T08:30:15 with an optional Z, +07:00 or +0700 offset; without one the time is UTC, like every loghunt output. The parser is a fixed regex rather than datetime.fromisoformat, which accepts different inputs on 3.10 and 3.12. --since is inclusive and --until exclusive, so --since 2026-10-20 --until 2026-10-21 is the whole day. Requests outside the window are counted and reported (terminal, JSON "window", HTML footer) but not analysed, so every count, including campaign totals, is per window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Writes a file the server or firewall loads as it is: nginx deny rules, an Apache 2.4 RequireAll block, ipset restore commands (separate IPv4 and IPv6 sets) or an nft -f table that drops both. The ipset and nftables files replace their old contents when loaded again, so a cron job never piles up stale entries. The nginx and Apache output passes nginx -t and httpd -t. The ROADMAP listed fail2ban; it has no file to load, only commands to run, so nftables took its place. Every format keeps only well-formed addresses, and an IPv4-mapped IPv6 address is written as its IPv4, once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.1.0 was never uploaded, so 0.2.0 is the first version on PyPI. It adds --allow, the threshold flags, --since/--until and --blocklist-format on top of 0.1.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Path.read_text() without an encoding uses cp1252 on Windows, so the window test read the report's "→" as mojibake and failed there. loghunt writes every file as UTF-8; the new tests now read them the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The first release meant for PyPI. 0.1.0 was never uploaded, so this PR also carries the release workflow (
dc3c206), which was committed but never pushed tomain.Each feature is its own commit. The last commit fixes a test that failed on Windows only: the test read the HTML report without an encoding, and Windows defaults to cp1252. loghunt itself was writing the report correctly.
What's new
--allow IP|CIDR|@FILE::ffff:x.x.x.xmatches the IPv4 range.--burst--flood--login-posts--probes--floodbelow--burstis rejected.--since/--until--sinceinclusive,--untilexclusive. Same accepted formats on Python 3.10 to 3.13.--blocklist-formatplain(default),nginx,apache,ipsetornftables, written so the server or firewall can load the file as it is. ipset and nftables files replace their old contents when reloaded.The JSON output gains
allowed,thresholdsandwindow; the terminal summary and HTML footer report the allowlist and window when they are used. Existing JSON keys are unchanged.ROADMAP.mdlays out 0.3 to 0.5 and what is not planned. One change from the first draft: fail2ban became nftables, because fail2ban has no file to load, only commands to run.Verification
pytest: 104 passed (55 before), checked locally on each intermediate commit; CI passes on all 6 jobs (Ubuntu 3.10 to 3.13, Windows, macOS)ruff checkandruff format --checkcleannginx -t, and the Apache file passeshttpd -t(Apache 2.4)elements = { }), but nobody has runipset restoreornft -c -fon them yetTo release after merging
loghunt, ownerwinxtxrgit, repositoryloghunt, workflowrelease.yml, environmentpypiv0.2.0. The workflow checks that the tag matches__version__, smoke-tests the wheel and uploads it🤖 Generated with Claude Code