Daily Security Statistics
A daily snapshot of the security numbers (created, resolved and auto-resolved findings, open findings by severity and priority, KEV, overdue, MTTR), stored for the whole platform and for every environment and team. The Security Trends panel (/docs/security/security-trends) reads these rows instead of rebuilding history every time; the compliance report (/docs/security/compliance-report) and the security KPIs of the Cruscotto and of the executive report use the same definitions but compute them live.
Overview
Every night the platform stores one SecurityDailyStat row per UTC day [00:00, 24:00) for the whole platform (the global row), plus one row for every Environment and one for every Team, even when they have no findings. A finding belongs to the environment and the team of its asset (environment, team_ref); findings of an asset without them count only in the global row, so the environment rows (and the team rows) do not add up to the global row. Deleting an environment or a team also deletes its daily rows. The rows are view-only in the Django admin (Security → Security daily statistics).
Definitions
Each row holds the numbers of its day:
- created: findings first detected in the day (detected_at)
- resolved: distinct findings with a resolution in the day in the Finding Timeline (/docs/security/finding-timeline), auto-resolutions included; a finding reopened and resolved again in the same day counts once. Findings resolved before the timeline existed count on the day of their resolved_at
- auto_resolved: distinct findings auto-resolved by the matchers in the day
- open_by_severity: open and acknowledged findings per severity (critical, high, medium, low, info; every key always present, 0 included)
- open_by_priority: the same findings per priority band (/docs/security/priority-score) P1..P4, plus unscored for findings without a band
- kev_open: open findings whose CVE is in the CISA KEV catalog
- overdue: open findings past their due date (/docs/security/sla) at the time of the snapshot
- mttr_hours_by_severity: mean time to resolve in hours (2 decimals) of the findings resolved in the day, per severity; null for a severity with no resolution that day
Schedule
The Celery task snapshot_security_stats runs every day at 00:15 UTC (beat entry snapshot-security-stats) and stores the day just ended, with the open findings as they are in the queue at that moment. Running it again for the same day replaces the rows of that day: there are never duplicates. It also accepts an ISO day (YYYY-MM-DD) to store a specific day; any other value is an error.
docker exec idp-backend python manage.py shell -c "from apps.security.tasks import snapshot_security_stats; print(snapshot_security_stats(day='2026-11-27'))"Backfill
After the installation the history can be rebuilt from the detection and resolution dates and the finding event trail. The command covers the last N days (default 180, at least 1) up to yesterday, starting no earlier than the first detected finding, and prints how many days it wrote and skipped. Days that already have a nightly snapshot are skipped; --force overwrites them too.
docker exec idp-backend python manage.py backfill_security_stats --days 180
docker exec idp-backend python manage.py backfill_security_stats --days 30 --forceMetadata
metadata.reconstructed tells a nightly snapshot (false) from a backfill reconstruction (true); metadata.as_of is the instant the open numbers refer to (the run time for a snapshot, 23:59:59.999999 UTC of the day for a reconstruction). A reconstruction rebuilds the status of each finding at the end of the day from its timeline, but uses the current severity, priority band, KEV flag and due date; a finding with no status event up to the end of the day gets its status from resolved_at alone (resolved, otherwise open), so a false positive or accepted risk decided before the timeline existed counts as open. metadata.approximations lists them (severity, priority_band, kev, due_at, legacy_status). Flows (created, resolved, auto_resolved, MTTR) are computed the same way in both modes.
{
"reconstructed": true,
"as_of": "2026-11-18T23:59:59.999999+00:00",
"approximations": ["severity", "priority_band", "kev", "due_at", "legacy_status"]
}