How prxcode/cross-layer-behavioral-detection works
This research system simulates compromised service-account behavior, correlates API and database audit events by trace ID, and compares four anomaly-detection configurations. The principal path is workload/client traffic through gateway and domain services into PostgreSQL, then telemetry collection, correlation, feature building, Isolation Forest scoring, and dashboard presentation. The README documents gateway, database, and deployment components whose source paths are absent from the supplied tree; they are represented only where that documented flow is meaningful. Relationships among unsampled components are omitted unless documented.
Main entry points: src/main.py Training and scoring API · models.py Four Isolation Forests · src/main.py Telemetry API and stream · run_matrix.py Experiment matrix
Components 21
Traffic simulation
- Workload generator
workload/src/generator.py - Attack scenarios
workload/src/attacks - Trace-ID gateway
Commerce services
- User service
services/user_service/src/routes.py - Order and payment service
services/order_service/src/routes.py - Admin service
services/admin_service/src/routes.py - PostgreSQL and pgaudit
Telemetry pipeline
- Nginx access logs
- pgaudit logs
- Log collectors
telemetry/src/collector.py - Trace correlation engine
telemetry/src/correlation.py - Correlation storage
telemetry/src/storage.py - Telemetry API and stream
telemetry/src/main.py
Detection research
- Feature builder
detector/src/features.py - Four Isolation Forests
detector/src/models.py - Training and scoring API
detector/src/main.py - Threshold calibration
detector/src/threshold.py - Experiment matrix
detector/src/experiments/run_matrix.py
Results and analysis
- SOC dashboard
dashboard/main.py - Reports and statistics
evaluation/src
Other components
- Client
Connections 26
- Client → Trace-ID gateway: sends requests
README.md - Workload generator → Trace-ID gateway: generates traffic
README.md - Attack scenarios → Trace-ID gateway: simulates attacks
README.md - Trace-ID gateway → User service: routes requests
README.md - Trace-ID gateway → Order and payment service: routes requests
README.md - Trace-ID gateway → Admin service: routes requests
README.md - Trace-ID gateway → Nginx access logs: writes access logs
README.md - User service → PostgreSQL and pgaudit: queries with trace ID
- Order and payment service → PostgreSQL and pgaudit: queries with trace ID
- Admin service → PostgreSQL and pgaudit: executes SQL
README.md - PostgreSQL and pgaudit → pgaudit logs: emits SQL audit
README.md - Nginx access logs → Log collectors: tails logs
- pgaudit logs → Log collectors: tails logs
- Log collectors → Trace correlation engine: ingests events
telemetry/src/main.py - Trace correlation engine → Correlation storage: stores records
telemetry/src/main.py - Correlation storage → Telemetry API and stream: serves records
telemetry/src/main.py - Telemetry API and stream → Training and scoring API: provides training data
detector/src/main.py - Training and scoring API → Feature builder: builds vectors
detector/src/main.py - Feature builder → Four Isolation Forests: supplies features
detector/src/main.py - Training and scoring API → Four Isolation Forests: trains and scores
detector/src/main.py - Threshold calibration → Four Isolation Forests: calibrates thresholds
detector/src/threshold.py - Training and scoring API → Experiment matrix: starts experiments
detector/src/main.py - Experiment matrix → Four Isolation Forests: loads model registry
detector/src/experiments/run_matrix.py - Telemetry API and stream → SOC dashboard: streams results
README.md - Training and scoring API → SOC dashboard: provides detections
README.md - Experiment matrix → Reports and statistics: produces experiment results
README.md