Skip to content

feat: add anomaly detection engine for behavioral security analytics - #60

Open
cto-new[bot] wants to merge 1 commit into
mainfrom
feat-securityanalytics-anomaly-engine
Open

feat: add anomaly detection engine for behavioral security analytics#60
cto-new[bot] wants to merge 1 commit into
mainfrom
feat-securityanalytics-anomaly-engine

Conversation

@cto-new

@cto-new cto-new Bot commented Nov 6, 2025

Copy link
Copy Markdown

Summary

This PR introduces an advanced security analytics anomaly detection engine that aggregates device/IP activity and applies configurable rules to detect suspicious behavioral anomalies in user log data.

Details

  • Adds a full aggregation layer for device, IP, and conversation activity with subnet-based NAT handling.
  • Implements detectors for quota spikes, abnormal login ratios, high request-to-login ratios, and unusual device/IP switching.
  • Adds SecurityAnomaly and AnomalyBaseline models/tables, with automatic deduplication and baseline learning.
  • Creates a real-time background worker to process anomalies non-blocking, configurable by Option and environment variables.
  • Exposes user and admin REST API endpoints for listing, stats, resolving, and configuring anomaly detection.
  • Adds full testing (unit, integration, API) and comprehensive documentation including configuration, tuning, and NAT considerations.
  • Migration required: runs new migrations for security_anomalies and anomaly_baselines tables.

Warning: Task VM test is not passing, cto.new will perform much better if you fix the setup

…ehavioral security analysis

Add comprehensive anomaly engine for security analytics, enabling automated
behavioral anomaly detection across device, IP, and login activity. Implements
data aggregation, configurable detection rules, baseline learning, and backend
persistence. Adds REST API endpoints and real-time background pipeline.

- Aggregates device/IP/conversation activities with sliding-window analysis
- Implements multiple detectors: quota spike, login anomaly, request ratio,
  device/IP switching (all with baseline-driven thresholds)
- Adds SecurityAnomaly table, baseline storage, and efficient deduplication
- Configurable via Option table / env; user/admin endpoints for list/query
- Engine runs as non-blocking goroutine and is concurrency safe

Migration: new tables (security_anomalies, anomaly_baselines); run migration
on deploy. Configuration may need tuning for production rollout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants