Add weekly organization security reports
This commit is contained in:
@@ -47,6 +47,28 @@ CREATE TABLE IF NOT EXISTS ocsentinel.ingest_nonce (
|
||||
CREATE INDEX IF NOT EXISTS ix_ocsentinel_ingest_nonce_expires
|
||||
ON ocsentinel.ingest_nonce (expires_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ocsentinel.weekly_organization_report (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
organization_id TEXT NOT NULL,
|
||||
organization_name TEXT NOT NULL,
|
||||
period_start_utc TIMESTAMPTZ NOT NULL,
|
||||
period_end_utc TIMESTAMPTZ NOT NULL,
|
||||
generated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
device_count INTEGER NOT NULL DEFAULT 0,
|
||||
warning_count INTEGER NOT NULL DEFAULT 0,
|
||||
critical_count INTEGER NOT NULL DEFAULT 0,
|
||||
total_events INTEGER NOT NULL DEFAULT 0,
|
||||
unique_ips INTEGER NOT NULL DEFAULT 0,
|
||||
cve_total INTEGER NOT NULL DEFAULT 0,
|
||||
cve_critical INTEGER NOT NULL DEFAULT 0,
|
||||
report_html TEXT NOT NULL,
|
||||
summary JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
UNIQUE (organization_id, period_start_utc)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_ocsentinel_weekly_report_organization_generated
|
||||
ON ocsentinel.weekly_organization_report (organization_id, generated_at DESC);
|
||||
|
||||
CREATE OR REPLACE VIEW ocsentinel.current_device_status AS
|
||||
SELECT DISTINCT ON (d.id)
|
||||
d.machine_name,
|
||||
|
||||
Reference in New Issue
Block a user