feat: Implement file-based audit exporter (JSON Lines) #135#160
Merged
feat: Implement file-based audit exporter (JSON Lines) #135#160
Conversation
Implement a file-based audit exporter that writes events in JSON Lines format for easy parsing and analysis. This completes the audit infrastructure by providing a production-ready exporter. Features: - JSON Lines format (one JSON object per line) - Append mode to preserve existing data - Log rotation based on file size - Optional gzip compression for rotated files - Thread-safe using async Mutex - Async I/O using tokio - Comprehensive test coverage (33 tests passing) Implementation: - Add FileExporter struct with BufWriter for efficient I/O - Add RotateConfig for configurable rotation behavior - Wire up FileExporter in AuditManager - Add async-compression and serde_json dependencies Closes #135
- Add file.rs to audit module structure listing - Document FileExporter features and capabilities - Add usage examples with rotation configuration - Document JSON Lines output format - Update future exporters list (file exporter is now implemented)
Member
Author
PR Finalization CompleteSummary
Changes Made
Verification ResultsAll checks passing. Ready for merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement a file-based audit exporter that writes events in JSON Lines format for easy parsing and analysis. This completes the audit infrastructure (#134) by providing a production-ready exporter.
Changes
Core Implementation
Features
Dependencies Added
async-compression(v0.4) with tokio and gzip featuresserde_json(v1.0) moved from dev-dependencies to dependenciesTesting
Testing Verification
Example Usage
Output Format
JSON Lines (one JSON object per line):
{"id":"123e4567-e89b-12d3-a456-426614174000","timestamp":"2024-01-15T10:30:00Z","event_type":"file_uploaded","session_id":"sess-001","user":"admin","client_ip":"192.168.1.100","path":"/data/report.pdf","bytes":1048576,"result":"success","protocol":"sftp"} {"id":"123e4567-e89b-12d3-a456-426614174001","timestamp":"2024-01-15T10:30:05Z","event_type":"auth_failure","session_id":"sess-002","user":"unknown","client_ip":"10.0.0.50","result":"failure","details":"Invalid password"}Closes #135