Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,64 @@ Security features for the SSH server (`src/server/security/`):
- Thread-safe with fail-closed behavior on lock contention
- Configuration via `allowed_ips` and `blocked_ips` in server config

### Audit Logging Module

Comprehensive audit logging infrastructure for the SSH server (`src/server/audit/`):

**Structure**:
- `mod.rs` - `AuditManager` for collecting and distributing audit events
- `event.rs` - `AuditEvent` type definitions and builder pattern
- `exporter.rs` - `AuditExporter` trait and `NullExporter` implementation

**Key Components**:

- **AuditEvent**: Represents discrete auditable actions with fields for:
- Unique event ID (UUID v4)
- Timestamp (UTC)
- Event type, session ID, username, client IP
- File paths, bytes transferred, operation result
- Protocol and additional details

- **EventType**: Categorizes security and operational events:
- Authentication: `AuthSuccess`, `AuthFailure`, `AuthRateLimited`
- Sessions: `SessionStart`, `SessionEnd`
- Commands: `CommandExecuted`, `CommandBlocked`
- File operations: `FileOpenRead`, `FileOpenWrite`, `FileRead`, `FileWrite`, `FileClose`, `FileUploaded`, `FileDownloaded`, `FileDeleted`, `FileRenamed`
- Directory operations: `DirectoryCreated`, `DirectoryDeleted`, `DirectoryListed`
- Filters: `TransferDenied`, `TransferAllowed`
- Security: `IpBlocked`, `IpUnblocked`, `SuspiciousActivity`

- **EventResult**: Operation outcomes (`Success`, `Failure`, `Denied`, `Error`)

- **AuditExporter Trait**: Interface for audit event destinations
- `export()` - Export single event
- `export_batch()` - Export multiple events (optimizable)
- `flush()` - Ensure pending events are written
- `close()` - Clean up resources

- **NullExporter**: No-op exporter for testing and disabled audit logging

- **AuditManager**: Central manager with async processing
- Background worker for non-blocking event processing
- Configurable buffering (buffer size, batch size)
- Periodic flush intervals
- Multiple exporter support
- Graceful shutdown with event flush

**Configuration**:
```rust
let config = AuditConfig::new()
.with_enabled(true)
.with_buffer_size(1000)
.with_batch_size(100)
.with_flush_interval(5);
```

**Future Exporters** (planned):
- File exporter for local audit logs
- OpenTelemetry exporter for distributed tracing
- Logstash exporter for centralized logging

### Server CLI Binary
**Binary**: `bssh-server`

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

**Key Components**:

Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ indicatif = "0.18.3"
rpassword = "7.4.0"
directories = "6.0.0"
dirs = "6.0"
chrono = "0.4.42"
chrono = { version = "0.4.42", features = ["serde"] }
glob = "0.3.3"
whoami = "2.0.1"
owo-colors = "4.2.3"
Expand Down Expand Up @@ -80,6 +80,7 @@ serial_test = "3.2"
insta = "1.44"
criterion = { version = "0.8", features = ["html_reports"] }
mockall = "0.14"
serde_json = "1.0"

[[bench]]
name = "large_output_benchmark"
Expand Down
3 changes: 2 additions & 1 deletion docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bssh is a high-performance parallel SSH command execution tool with SSH-compatib
- **SSH Server Module** - SSH server implementation using russh (see main ARCHITECTURE.md)
- **Server Authentication** - Authentication providers including public key verification (see main ARCHITECTURE.md)
- **SFTP Handler** - SFTP subsystem with path traversal prevention and chroot-like isolation (see main ARCHITECTURE.md)
- **Audit Logging** - Audit event types, exporters, and async event processing (see main ARCHITECTURE.md)

## Navigation

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