Skip to content

Commit f345d80

Browse files
committed
docs: Add comprehensive documentation for audit logging infrastructure
- Add Audit Logging Module section to ARCHITECTURE.md with complete description of AuditEvent, EventType, EventResult, AuditExporter trait, NullExporter, and AuditManager components - Update server structure in ARCHITECTURE.md to include audit/ module - Update docs/architecture/README.md to reference audit logging - Update code organization to show audit/ in server directory
1 parent 4ed85a2 commit f345d80

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

ARCHITECTURE.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,64 @@ Security features for the SSH server (`src/server/security/`):
213213
- Thread-safe with fail-closed behavior on lock contention
214214
- Configuration via `allowed_ips` and `blocked_ips` in server config
215215

216+
### Audit Logging Module
217+
218+
Comprehensive audit logging infrastructure for the SSH server (`src/server/audit/`):
219+
220+
**Structure**:
221+
- `mod.rs` - `AuditManager` for collecting and distributing audit events
222+
- `event.rs` - `AuditEvent` type definitions and builder pattern
223+
- `exporter.rs` - `AuditExporter` trait and `NullExporter` implementation
224+
225+
**Key Components**:
226+
227+
- **AuditEvent**: Represents discrete auditable actions with fields for:
228+
- Unique event ID (UUID v4)
229+
- Timestamp (UTC)
230+
- Event type, session ID, username, client IP
231+
- File paths, bytes transferred, operation result
232+
- Protocol and additional details
233+
234+
- **EventType**: Categorizes security and operational events:
235+
- Authentication: `AuthSuccess`, `AuthFailure`, `AuthRateLimited`
236+
- Sessions: `SessionStart`, `SessionEnd`
237+
- Commands: `CommandExecuted`, `CommandBlocked`
238+
- File operations: `FileOpenRead`, `FileOpenWrite`, `FileRead`, `FileWrite`, `FileClose`, `FileUploaded`, `FileDownloaded`, `FileDeleted`, `FileRenamed`
239+
- Directory operations: `DirectoryCreated`, `DirectoryDeleted`, `DirectoryListed`
240+
- Filters: `TransferDenied`, `TransferAllowed`
241+
- Security: `IpBlocked`, `IpUnblocked`, `SuspiciousActivity`
242+
243+
- **EventResult**: Operation outcomes (`Success`, `Failure`, `Denied`, `Error`)
244+
245+
- **AuditExporter Trait**: Interface for audit event destinations
246+
- `export()` - Export single event
247+
- `export_batch()` - Export multiple events (optimizable)
248+
- `flush()` - Ensure pending events are written
249+
- `close()` - Clean up resources
250+
251+
- **NullExporter**: No-op exporter for testing and disabled audit logging
252+
253+
- **AuditManager**: Central manager with async processing
254+
- Background worker for non-blocking event processing
255+
- Configurable buffering (buffer size, batch size)
256+
- Periodic flush intervals
257+
- Multiple exporter support
258+
- Graceful shutdown with event flush
259+
260+
**Configuration**:
261+
```rust
262+
let config = AuditConfig::new()
263+
.with_enabled(true)
264+
.with_buffer_size(1000)
265+
.with_batch_size(100)
266+
.with_flush_interval(5);
267+
```
268+
269+
**Future Exporters** (planned):
270+
- File exporter for local audit logs
271+
- OpenTelemetry exporter for distributed tracing
272+
- Logstash exporter for centralized logging
273+
216274
### Server CLI Binary
217275
**Binary**: `bssh-server`
218276

@@ -274,6 +332,7 @@ SSH server implementation using the russh library for accepting incoming connect
274332
- `exec.rs` - Command execution for SSH exec requests
275333
- `sftp.rs` - SFTP subsystem handler with path traversal prevention
276334
- `auth/` - Authentication provider infrastructure
335+
- `audit/` - Audit logging infrastructure (event types, exporters, manager)
277336

278337
**Key Components**:
279338

docs/architecture/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ bssh is a high-performance parallel SSH command execution tool with SSH-compatib
3737
- **SSH Server Module** - SSH server implementation using russh (see main ARCHITECTURE.md)
3838
- **Server Authentication** - Authentication providers including public key verification (see main ARCHITECTURE.md)
3939
- **SFTP Handler** - SFTP subsystem with path traversal prevention and chroot-like isolation (see main ARCHITECTURE.md)
40+
- **Audit Logging** - Audit event types, exporters, and async event processing (see main ARCHITECTURE.md)
4041

4142
## Navigation
4243

@@ -83,7 +84,7 @@ src/
8384
├── interactive/ → Interactive Mode
8485
├── jump/ → Jump Host Support
8586
├── forward/ → Port Forwarding
86-
├── server/ → SSH Server (handler, session, config/, auth/)
87+
├── server/ → SSH Server (handler, session, config/, auth/, audit/)
8788
├── shared/ → Shared utilities (validation, rate limiting, auth types, errors)
8889
├── security/ → Security utilities (re-exports from shared for compatibility)
8990
└── commands/ → Command Implementations

0 commit comments

Comments
 (0)