Add rate-based burst-detection foundation, propose-only (D-0051) #128
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/burst-detection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What does this PR do?
Adds a generic, propose-only rate-based burst-detection foundation (D-0051). Single-event detection rules cannot count, so this introduces a per-(signal, source) sliding-window aggregate:
BurstDetectormaintains windowed counts and, when a signal reaches its threshold within the window, proposes an incident for review.CorrelationWorker(the single stage every ingested event passes through), so no new pipeline queue is added.burst:{signal}:{sourceKey}(never merged with the per-IP incidents fromTimeWindowCorrelator), carrying the windowed event ids and one evidence item scoredmin(3.0 + 0.2 * (count - threshold), 5.0), then flows through the existing classification/policy/decision path to/decisions.AuthFailureBurstSignal: LoginFailed/TotpFailed/StepUpFailed/WebAuthnFailed, keyed by source IP).burst_windows,burst_cooldowns) with per-record pruning and an atomic cooldown upsert, so counts survive restarts and concurrent instances cannot both fire.GlobalEnabled,AuthFailureEnabled,AuthFailureThreshold,AuthFailureWindowSeconds,AuthFailureCooldownSeconds,AuthFailureActionEligible) are a database-owned single-rowburst_detection_settingstable following the D-0050 config-store pattern: seeded create-only fromBurstDetectionOptions, edited on/configuration#burst-detection(step-up gated, audited), hot-refreshed on theviegard_config_burst_detection_settingsNOTIFY channel, and exposed read-only atGET /api/v1/burst/settings.The originating slow-loris HTTP 408 case remains deferred (TODO Path A vs B) as a future consumer of this foundation.
Fixes # N/A
How was this tested?
dotnet build- 0 errors, 0 warnings (full solution)dotnet test- all tests pass (207 AdminApi, 553 Application; new burst tests included)GET /api/v1/burst/settingsreturns correct defaults and requires auth;/configurationrenders the burst section; authenticated edit round-trip persisted new values withversionincremented andseededflipping to true.New unit/integration tests: read-only API defaults and round-trip, save endpoint (persist, unchecked-box disable, invalid value, version conflict), and Postgres window/cooldown round-trip. The three burst tables were added to the integration-test truncate list.
Checklist
Complete the propose-only rate-based burst-detection foundation on top of the Application spine and Postgres stores. The detector is driven from CorrelationWorker (the single every-event stage), fires a distinct burst:{signal}:{sourceKey} incident through the existing classification/policy/decision path, and is fed by the durable Postgres window and cooldown stores. - PipelineHost: seed, NOTIFY-driven refresh, and logging diagnostics workers; BurstDetector integration in CorrelationWorker; DI wiring. - AdminApi: burst-detection options/store/source DI; step-up-gated, audited save endpoint and TryRead form parsing; read-only GET /api/v1/burst/settings; /configuration#burst-detection section. - Tests: read-only API defaults/round-trip, save endpoint (persist, unchecked-box disable, invalid, version conflict), and Postgres window/cooldown round-trip; burst tables added to the truncate list. Verified against the in-memory rig (startup, defaults, authenticated edit round-trip, version increment). - Docs: DECISIONS D-0051, AGENT-README, ARCHITECTURE, TODO, read-only-api. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>