Skip to content

Commit eabae29

Browse files
committed
Implemented comprehensive architecture improvements and configuration validation
- Added service lifetime audit and configuration validators - Implemented global exception handling and correlation ID middleware - Added JWT token blacklist and BCrypt password hashing services - Enhanced startup validation with fail-fast error handling - Added structured logging and request tracing - Improved PowerShell compatibility and documentation
1 parent 4322457 commit eabae29

24 files changed

+1799
-63
lines changed

README.md

Lines changed: 99 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
![GitHub Tag](https://img.shields.io/github/v/tag/MLidstrom/Castellan)
1212
[![.NET](https://img.shields.io/badge/.NET-8.0-512BD4?logo=.net)](https://dotnet.microsoft.com/)
1313
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
14-
[![Platform](https://img.shields.io/badge/Platform-Windows-blue.svg)](https://www.microsoft.com/windows)
14+
[![Platform](https://img.shields.io/badge/Platform-Windows%7CLinux%7CmacOS-blue.svg)](https://www.microsoft.com/windows)
15+
[![Security](https://img.shields.io/badge/Security-BCrypt%20%7C%20JWT-green.svg)](https://auth0.com/blog/hashing-in-action-understanding-bcrypt/)
16+
[![Reliability](https://img.shields.io/badge/Reliability-Enterprise%20Grade-blue.svg)](#observability--reliability)
1517
[![AI](https://img.shields.io/badge/AI-Powered-orange.svg)](https://openai.com/)
1618
[![MITRE](https://img.shields.io/badge/MITRE-ATT%26CK-darkred.svg)](https://attack.mitre.org/)
1719

1820
</div>
1921

20-
## AI‑Powered Windows Security Monitoring
22+
## AI‑Powered Cross-Platform Security Monitoring
2123

22-
**Castellan** is an advanced security monitoring and threat detection platform that transforms Windows event logs into actionable security intelligence using AI-powered analysis, vector search, and real-time correlation. It also includes proactive threat scanning capabilities to detect malware and backdoors on your system.
24+
**Castellan** is an advanced security monitoring and threat detection platform that transforms Windows event logs into actionable security intelligence using AI-powered analysis, vector search, and real-time correlation. With enterprise-grade security features including BCrypt password hashing, JWT token management, and cross-platform deployment capabilities, it provides comprehensive threat detection for Windows, Linux, and macOS environments.
2325

2426
> **Castellan** (noun): A governor or warden of a castle or fortification; a person responsible for the defense and security of a stronghold. From the medieval Latin *castellanus*, meaning "pertaining to a castle." The name reflects our mission to provide vigilant security monitoring and defense for your digital infrastructure. ([Source: Merriam-Webster](https://www.merriam-webster.com/dictionary/castellan))
2527
@@ -53,12 +55,24 @@
5355
- **🆕 Teams/Slack Integration** - Real-time security alerts in Microsoft Teams and Slack channels
5456
- **Desktop Notifications** - Real-time security alerts
5557
- **Web Admin Interface** - React-based management dashboard
58+
- **Cross-Platform Support** - Unified scripts for Windows, Linux, and macOS
5659
- **Local Deployment** - No cloud dependencies, runs entirely on your local infrastructure
5760

61+
### 🔒 **Enterprise Security**
62+
- **BCrypt Password Hashing** - Industry-standard password security with configurable work factors
63+
- **JWT Token Management** - Secure refresh token rotation and server-side invalidation
64+
- **Token Blacklisting** - Real-time token revocation with automatic cleanup
65+
- **Password Complexity Validation** - Comprehensive password strength requirements
66+
- **Audit Trail** - Complete authentication event logging for security monitoring
67+
- **Configuration Validation** - Startup validation prevents deployment with invalid security settings
68+
- **Error Handling** - Consistent security error responses with correlation tracking
69+
5870
### 🧪 **Quality & Testing**
59-
- **Comprehensive Test Suite** - 450+ tests with 98%+ success rate covering all critical functionality
60-
- **Production Ready** - Robust error handling, advanced mocking, and comprehensive validation
71+
- **Comprehensive Test Suite** - 375 tests with 97.6% success rate (366 passing, 9 functional tests require fixes) covering all critical functionality
72+
- **Production Ready** - **Compilation Fixed** - All build errors resolved (January 2025), robust error handling, advanced mocking, and comprehensive validation
6173
- **Continuous Validation** - Automated testing for controllers, services, and integration scenarios
74+
- **Enterprise Architecture** - Service lifetime optimization, configuration validation, and startup safety checks
75+
- **Structured Observability** - Correlation ID tracking, comprehensive logging, and request tracing
6276

6377
## 📊 Performance & Scale
6478

@@ -145,6 +159,47 @@ flowchart LR
145159
style M fill:#e3f2fd,color:#000
146160
```
147161

162+
## 🔐 Security Architecture
163+
164+
**Enterprise-Grade Authentication System:**
165+
```
166+
Client Request ──► JWT Validation ──► Token Blacklist Check ──► API Access
167+
│ │ │
168+
▼ ▼ ▼
169+
Login/Register ──► BCrypt Hashing ──► Refresh Token ──► Secure Session
170+
```
171+
172+
**Security Features:**
173+
- **Password Security**: BCrypt hashing with configurable work factors (4-12 rounds)
174+
- **Token Management**: JWT with secure refresh token rotation and automatic expiration
175+
- **Token Blacklisting**: Real-time token revocation with in-memory cache and cleanup
176+
- **Complexity Validation**: Enforced password strength requirements (length, character types)
177+
- **Audit Trail**: Comprehensive authentication event logging for security monitoring
178+
- **Session Security**: Automatic token expiration, renewal, and secure refresh handling
179+
- **Multi-layered Defense**: Multiple security checks at authentication, authorization, and session levels
180+
- **Request Tracing**: Every API request tracked with unique correlation IDs for security incident investigation
181+
- **Configuration Safety**: Startup validation prevents deployment with invalid security configurations
182+
183+
## 🔍 Observability & Reliability
184+
185+
**Enterprise-Grade Operations:**
186+
```
187+
Request ──► Correlation ID ──► Structured Logging ──► Error Handling ──► Response
188+
│ │ │ │
189+
▼ ▼ ▼ ▼
190+
Tracing ──► Performance Metrics ──► Exception Context ──► Audit Trail
191+
```
192+
193+
**Reliability Features:**
194+
- **Correlation Tracking**: Unique request IDs for complete request lifecycle tracing
195+
- **Structured Logging**: JSON-formatted logs with contextual information for analysis
196+
- **Global Exception Handling**: Consistent error responses across all API endpoints
197+
- **Service Validation**: Startup checks ensure all critical services are properly configured
198+
- **Configuration Validation**: Prevents deployment with invalid system configurations
199+
- **Performance Monitoring**: Request duration tracking and service health metrics
200+
- **Fail-Fast Architecture**: Application stops startup on critical configuration errors
201+
- **Request Context**: Complete request information available for debugging and security analysis
202+
148203
## 🔔 Notification Services
149204

150205
Castellan provides multiple channels for real-time security alert delivery:
@@ -226,6 +281,21 @@ ollama pull llama3.1:8b-instruct-q8_0 # LLM model: https://ollama.com/library
226281
```
227282

228283
### 6. Start All Services
284+
285+
**Cross-Platform (Unified Commands)**
286+
```bash
287+
# Use Makefile for consistent experience across all platforms
288+
make start # Build and start all services
289+
make start-bg # Start in background
290+
make status # Check component status
291+
make stop # Stop all services
292+
make test # Run all tests
293+
make help # Show all available commands
294+
```
295+
296+
**Platform-Specific Commands**
297+
298+
*Windows (PowerShell):*
229299
```powershell
230300
# Start everything (Worker handles all orchestration)
231301
.\scripts\start.ps1
@@ -234,7 +304,6 @@ ollama pull llama3.1:8b-instruct-q8_0 # LLM model: https://ollama.com/library
234304
.\scripts\start.ps1 # Standard start with build
235305
.\scripts\start.ps1 -NoBuild # Skip build step
236306
.\scripts\start.ps1 -Background # Run in background
237-
.\scripts\start.ps1 -NoBuild -Background # Skip build + background
238307
239308
# Check service status:
240309
.\scripts\status.ps1 # Basic status check
@@ -243,11 +312,22 @@ ollama pull llama3.1:8b-instruct-q8_0 # LLM model: https://ollama.com/library
243312
# Stop all services:
244313
.\scripts\stop.ps1 # Graceful stop
245314
.\scripts\stop.ps1 -Force # Force stop all
246-
.\scripts\stop.ps1 -KeepQdrant # Stop but keep Qdrant running
315+
```
316+
317+
*Linux/macOS (Bash):*
318+
```bash
319+
# Start everything
320+
./scripts/start.sh # Standard start with build
321+
./scripts/start.sh --no-build # Skip build step
322+
./scripts/start.sh --background # Run in background
323+
324+
# Check service status:
325+
./scripts/status.sh # Basic status check
326+
./scripts/status.sh --detailed # Detailed component info
247327

248-
# Run tests:
249-
.\scripts\run-tests.ps1 # Run all tests
250-
.\scripts\run-tests.ps1 -Verbosity detailed # Verbose output
328+
# Stop all services:
329+
./scripts/stop.sh # Graceful stop
330+
./scripts/stop.sh --force # Force stop all
251331
```
252332

253333
**🛡️ Automatic MITRE ATT&CK Import**: On first startup, Castellan automatically downloads and imports 800+ official MITRE ATT&CK techniques from GitHub. This provides rich intelligence for security event analysis and tooltip descriptions. The import runs in the background and requires internet connectivity.
@@ -328,6 +408,8 @@ Castellan uses a hybrid data storage approach for optimal performance and functi
328408

329409
## 🔧 Configuration
330410

411+
**⚠️ Configuration Validation**: Castellan automatically validates all configuration settings at startup. Invalid configurations will prevent the application from starting with clear error messages indicating what needs to be fixed.
412+
331413
### Environment Variables
332414
```powershell
333415
# Authentication Configuration (REQUIRED)
@@ -367,9 +449,15 @@ dotnet build -c Release
367449
- **[Authentication Setup](docs/AUTHENTICATION_SETUP.md)** - Security configuration and credential setup
368450
- **[Getting Started](docs/GETTING_STARTED.md)** - Quick start guide for development
369451
- **[Startup Configuration](docs/STARTUP_CONFIGURATION.md)** - Service orchestration and startup management
370-
- **[Test Suite](src/Castellan.Tests/)** - Comprehensive test coverage with 375 tests (95.7% success rate)
452+
- **[Test Suite](src/Castellan.Tests/)** - Comprehensive test coverage with 375 tests (97.6% success rate - 366 passing, 9 functional tests pending fixes)
453+
454+
### Architecture & Quality
455+
- **[Improvement Plan](IMPROVEMENT_PLAN.md)** - Comprehensive code improvement roadmap and progress tracking
456+
- **[Service Lifetime Audit](SERVICE_LIFETIME_AUDIT.md)** - Dependency injection optimization and service lifetime analysis
457+
- **[Phase 2 Completion](PHASE_2_COMPLETION_SUMMARY.md)** - Architecture and configuration improvements summary
371458

372459
### Development & Operations
460+
- **[Windows PowerShell Compatibility](docs/WINDOWS_POWERSHELL_COMPATIBILITY.md)** - Native Windows PowerShell 5.1 support guide
373461
- **[Windows Logging Hardening](scripts/enable-logging-hardening.md)** - Windows audit policy configuration guide
374462
- **[Troubleshooting Guide](docs/TROUBLESHOOTING.md)** - Common issues and solutions
375463

docs/TROUBLESHOOTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ If you're still experiencing issues after trying these solutions:
179179

180180
## Common Error Messages
181181

182-
### "Unable to resolve service for type"
183-
- **Cause**: Dependency injection configuration issue
184-
- **Solution**: Ensure all required services are registered in `Program.cs`
185-
186182
### "Collection does not exist"
187183
- **Cause**: Qdrant vector database collection not initialized
188184
- **Solution**: Restart the application to auto-create collections

0 commit comments

Comments
 (0)