Journal events to local ban requests
Journal events to local ban requests
Read references/specification.md and references/engineering-contract.md. For the blocking project’s action client, require the locally pinned bmforge-zmq skill and its existing REQ/REP envelope; select ZMQ explicitly if absent. Do not require ZMQ, Fail2ban or nftables in a producing application: it should independently select bmforge-security-events and simply call emit("abuse").
- Read only native systemd journal records from the actual producing service, with
backend = systemdandjournalmatch = _SYSTEMD_UNIT=<real-service>.service. No file log path, file rotation, log watcher, second delivery channel or new daemon. The host Fail2ban interpreter needspython3-systemd(or distribution equivalent); this is not an application venv dependency. - Match the producer’s timestamp-free
SECURITY event=<name> ip=<numeric address>journalMESSAGE. Fail2ban reconstructs a prefix from journal hostname, identifier and PID metadata; include nativecommon.conf, selectlogtype = journal, and anchor the filter at^%(__prefix_line)sSECURITY.... The journal owns event time. Verify real IPv4/IPv6 usingfail2ban-regex ... systemd-journaland unit-scopedjournalmatch, not a synthetic unprefixed log. - Keep event meaning explicit. If one event means confirmed abuse, use
maxretry = 1; if each event is a countable action, let Fail2ban apply the policy’sfindtime/maxretrythreshold across workers. The producer has no retries, counters, queues, IP state or knowledge of enforcement. Use nativeignoreipand finitebantimefor jail tickets only; the blocking service chooses the real kernel ban duration. - Create only the current, application-owned Fail2ban
filter.d/*.conf, disabled-by-defaultjail.d/*.conf, andaction.d/*.confban-only action in the blocking project. Operator.localoverrides remain separately owned, but must not change required backend, journalmatch or action hooks. Reject conflicting effective configuration before activating. No automatic legacy file migration,configparsertranslator, or compatibility support. Refactor older applications explicitly when adopting the new contract. Pass the validated matched IP and fixed jail/source name, never raw log lines. Keepactionunban,actionstopandactionflushempty. - Reuse existing BMForge ZMQ for a bounded acknowledged REQ/REP call; an error, lost reply, unavailable listener or rejection produces a nonzero result. No hidden retry, claimed success, or firewall fallback. No new transport/client in the event producer.
- Leave the nftables enforcement contract unchanged. The local service selects the duration; the kernel owns active timed bans. A restored ticket may issue an ordinary request without duplicate or expiry tracking. Never implement a ban map, source ledger, replay worker, new database, generic Fail2ban wrapper, second firewall backend or centralized controller.
- Use separate native checks for configuration (
fail2ban-client -t/-d), the host daemon interpreter (import systemd.journal), journal unit access (journalctl -u ... -o cat/-o verbose), and actual matching (fail2ban-regex ... systemd-journal). Then exercise the boundary with real application requests and two independent countable event types (bad_request: 3/60s;auth_failure: 5/300s in disposable test only). Show each jail counts its own events and overlapping jails can send independent ban requests for the same IP, without app-side state. A logfile fixture cannot prove delivery. Do not revalidate the existing nftables core-blocking contract. - Mark the owning action-client module with
BMFORGE_COMPONENT = {"id": "bmforge.fail2ban", "spec_version": "0.3.1"}. Do not enable a production jail or mutate consumer repositories merely by selecting/updating this pinned skill.