Harden authentication and session audit ingestion - #68
Harden authentication and session audit ingestion#68somethingwithproof wants to merge 11 commits into
Conversation
- ingest Cacti user_log events with transactional deduplication - capture logout completion and authorization-denied events - add brute-force detection with atomic alert throttling - preserve deduplication state across audit-log purges - add authentication settings and upgrade handling - test Cacti 1.2.x and develop compatibility in CI - add behavioral coverage for races, retries, paging, and retention
And fix bruteforce detection settings
2653946 to
f14b9bb
Compare
Cacti core now requires PHP >= 8.2, so the 8.1 integration job fails the composer platform check; Ubuntu Noble also lacks libapache2-mod-php for non-native versions without the ondrej PPA. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Cacti and the plugin require PHP >= 8.2. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
plugin_audit_uninstall() can remove plugin tables/settings even when core-table index removal fails, risking a broken partial-uninstall while still returning failure.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens and expands the Cacti Audit plugin to capture authentication/session security events (login outcomes, authorization denials, logout completion) with durable, replay-safe ingestion from Cacti’s user_log, while tightening admin controls around audit configuration and improving CI/test coverage for the new behavior.
Changes:
- Add poller-driven
user_logingestion with a durable deduplication table, deterministic event UUIDs, bounded retries, and replay-safe cleanup. - Gate authentication auditing behind explicit opt-in (admin-only UI controls + CLI index setup) and add new hooks for denied/teardown events.
- Bump plugin version to 1.6 and expand unit/integration tests + CI workflows to validate the new auth ingestion and lifecycle behavior.
File summaries
| File | Description |
|---|---|
| tests/syslog_queue_test.php | Updates syslog queue test stubs to account for audit_log availability gating. |
| tests/setup_index_test.php | Adds behavioral tests for plugin-owned user_log index create/repair/remove flows. |
| tests/setup_defaults_test.php | Adds tests ensuring install/upgrade defaults for auth auditing are safe and non-destructive. |
| tests/security_functions_test.php | Adds coverage ensuring already-delivered external events are not re-appended. |
| tests/controller_security_test.php | Extends static guard assertions for v1.6 upgrade path, hooks, and admin-only settings exposure. |
| tests/auth_sql_integration_test.php | Adds live-DB integration test for auth ingestion SQL + identity/index prerequisites. |
| tests/auth_audit_test.php | Adds extensive behavioral tests for auth/session ingestion, retries, dedupe, and denied/logout hooks. |
| tests/auth_audit_coverage_test.php | Adds a phpdbg-based gate to enforce 100% executable-line coverage for auth auditing code paths. |
| setup.php | Registers new hooks, adds auth defaults + upgrade steps, adds user_log state/index helpers, tightens admin settings exposure, and adjusts uninstall cleanup. |
| README.md | Documents the new auth ingestion model, event taxonomy, dedupe guarantees, and operational setup steps. |
| phpstan/stubs/cacti.stubs.php | Updates stubs with phpstan impurity annotations for DB/log side-effect functions. |
| phpstan-baseline.neon | Updates baseline counts and adds suppressions for new test code patterns. |
| INFO | Bumps plugin version to 1.6. |
| CHANGELOG.md | Adds a 1.6 release section describing the new authentication/session auditing and related hardening. |
| audit.php | Hardens event lookup and syslog details rendering against false/empty DB returns. |
| audit_syslog.php | Gates syslog enqueue/processing on audit_log table availability to tolerate uninstall/lifecycle edges. |
| audit_functions.php | Adds audit_log_table_available(), makes external/syslog delivery idempotent, adds deterministic UUID support, and implements auth ingestion + denied/logout hook handlers. |
| audit_auth_indexes.php | Adds a CLI helper to verify identity contract and create the required user_log indexes. |
| .github/workflows/plugin-ci-workflow.yml | Expands integration coverage across Cacti branches and exercises auth ingestion end-to-end, including uninstall cleanup. |
| .github/workflows/code-quality.yml | Updates the PHP matrix and runs the new auth/setup test suites in the quality workflow. |
Review details
- Files reviewed: 20/20 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The pre-destroy logout event records regardless of the master switch so upgrades keep it, which is what the test asserts. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Summary
Validation
Operator note
Before enabling authentication auditing, run php plugins/audit/audit_auth_indexes.php. This keeps core-table DDL out of checkbox and poller paths.