Add comprehensive audit logging infrastructure for bssh-server with:
- AuditEvent type with id, timestamp, event_type, session_id, user,
client_ip, path, bytes, result, details, and protocol fields
- EventType enum covering authentication, session, command, file
operations, directory operations, filters, and security events
- EventResult enum (Success, Failure, Denied, Error)
- AuditExporter trait with export, export_batch, flush, and close methods
- NullExporter implementation that discards events for testing
- AuditManager managing multiple exporters with buffering and
background worker for async processing
- Comprehensive unit tests for all components
Files created:
- src/server/audit/mod.rs - Audit manager and configuration
- src/server/audit/event.rs - Event type definitions
- src/server/audit/exporter.rs - Exporter trait and NullExporter
Files modified:
- src/server/mod.rs - Added audit module export
- Cargo.toml - Added serde feature to chrono, serde_json to dev-dependencies
All tests passing (19 tests).
Summary
Implements the audit logging infrastructure for bssh-server as specified in #134.
This PR provides:
Changes
New Files
src/server/audit/mod.rs- Audit manager and configurationsrc/server/audit/event.rs- Event type definitionssrc/server/audit/exporter.rs- Exporter trait and NullExporterModified Files
src/server/mod.rs- Added audit module exportCargo.toml- Added serde feature to chrono, serde_json to dev-dependenciesImplementation Details
AuditEvent
EventType
Covers all audit scenarios:
AuditManager
Test Coverage
All 19 tests passing:
Quality Checks
cargo test audit- All 19 tests passingcargo clippy -- -D warnings- No warningscargo fmt- Code formattedcargo build --lib- Compiles successfullyRelated Issues
Closes #134
Part of #123 (bssh-server implementation)
Depends on #124 (shared module structure)
Future Work
This PR provides the foundation for: