mock data
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
-- Migration: S001_demo_seed
|
||||
-- Category: seed
|
||||
-- Description: Demo data for Notify module (channels, templates, rules, incidents)
|
||||
-- Idempotent: ON CONFLICT DO NOTHING
|
||||
|
||||
-- ============================================================================
|
||||
-- Notification Channels
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO notify.channels (id, tenant_id, name, channel_type, enabled, config, created_by)
|
||||
VALUES
|
||||
('e0000001-0000-0000-0000-000000000001', 'demo-prod', 'ops-email', 'email', true,
|
||||
'{"smtpHost": "smtp.stella-ops.local", "smtpPort": 587, "from": "alerts@stella-ops.local", "useTls": true}'::jsonb, 'admin'),
|
||||
('e0000001-0000-0000-0000-000000000002', 'demo-prod', 'security-slack', 'slack', true,
|
||||
'{"webhookUrl": "https://hooks.slack.example.com/services/demo", "channel": "#security-alerts", "username": "StellaOps"}'::jsonb, 'admin'),
|
||||
('e0000001-0000-0000-0000-000000000003', 'demo-prod', 'ci-webhook', 'webhook', true,
|
||||
'{"url": "https://ci.stella-ops.local/api/webhooks/stellaops", "method": "POST", "headers": {"X-Source": "stellaops"}}'::jsonb, 'admin')
|
||||
ON CONFLICT (tenant_id, name) DO NOTHING;
|
||||
|
||||
-- ============================================================================
|
||||
-- Notification Templates
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO notify.templates (id, tenant_id, name, channel_type, subject_template, body_template, locale)
|
||||
VALUES
|
||||
('e0000002-0000-0000-0000-000000000001', 'demo-prod', 'critical-vulnerability', 'email',
|
||||
'CRITICAL: New vulnerability {{vuln_id}} detected',
|
||||
'A critical vulnerability has been detected in your environment.\n\nVulnerability: {{vuln_id}}\nSeverity: {{severity}}\nAffected: {{affected_count}} components\nCVSS: {{cvss_score}}\n\nAction Required: Review and remediate within {{sla_hours}} hours.\n\nView details: {{dashboard_url}}',
|
||||
'en'),
|
||||
('e0000002-0000-0000-0000-000000000002', 'demo-prod', 'scan-complete', 'email',
|
||||
'Scan Complete: {{scan_name}} - {{result}}',
|
||||
'Vulnerability scan has completed.\n\nScan: {{scan_name}}\nResult: {{result}}\nFindings: {{finding_count}} ({{critical_count}} critical, {{high_count}} high)\nDuration: {{duration}}\n\nView report: {{report_url}}',
|
||||
'en'),
|
||||
('e0000002-0000-0000-0000-000000000003', 'demo-prod', 'policy-violation', 'slack',
|
||||
NULL,
|
||||
'{"blocks":[{"type":"section","text":{"type":"mrkdwn","text":"*Policy Violation* :warning:\n*Pack:* {{pack_name}}\n*Rule:* {{rule_name}}\n*Artifact:* {{artifact_id}}\n*Severity:* {{severity}}"}}]}',
|
||||
'en'),
|
||||
('e0000002-0000-0000-0000-000000000004', 'demo-prod', 'release-gate-result', 'email',
|
||||
'Release Gate {{result}}: {{release_name}}',
|
||||
'Release gate evaluation complete.\n\nRelease: {{release_name}}\nEnvironment: {{environment}}\nResult: {{result}}\nGate: {{gate_name}}\n\n{{#if blocked}}Blocking Issues:\n{{#each issues}}- {{this}}\n{{/each}}{{/if}}',
|
||||
'en'),
|
||||
('e0000002-0000-0000-0000-000000000005', 'demo-prod', 'feed-sync-failure', 'webhook',
|
||||
NULL,
|
||||
'{"event":"feed_sync_failure","source":"{{source_name}}","error":"{{error_message}}","timestamp":"{{timestamp}}","retryCount":{{retry_count}}}',
|
||||
'en')
|
||||
ON CONFLICT (tenant_id, name, channel_type, locale) DO NOTHING;
|
||||
|
||||
-- ============================================================================
|
||||
-- Notification Rules (routing)
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO notify.rules (id, tenant_id, name, description, enabled, priority, event_types, channel_ids, template_id)
|
||||
VALUES
|
||||
('e0000003-0000-0000-0000-000000000001', 'demo-prod', 'critical-vuln-all-channels', 'Route critical vulnerabilities to all channels', true, 10,
|
||||
ARRAY['vulnerability.critical', 'vulnerability.kev'],
|
||||
ARRAY['e0000001-0000-0000-0000-000000000001'::uuid, 'e0000001-0000-0000-0000-000000000002'::uuid],
|
||||
'e0000002-0000-0000-0000-000000000001'),
|
||||
('e0000003-0000-0000-0000-000000000002', 'demo-prod', 'scan-results-email', 'Email scan results to ops team', true, 20,
|
||||
ARRAY['scan.completed', 'scan.failed'],
|
||||
ARRAY['e0000001-0000-0000-0000-000000000001'::uuid],
|
||||
'e0000002-0000-0000-0000-000000000002'),
|
||||
('e0000003-0000-0000-0000-000000000003', 'demo-prod', 'policy-violations-slack', 'Send policy violations to Slack', true, 15,
|
||||
ARRAY['policy.violation'],
|
||||
ARRAY['e0000001-0000-0000-0000-000000000002'::uuid],
|
||||
'e0000002-0000-0000-0000-000000000003')
|
||||
ON CONFLICT (tenant_id, name) DO NOTHING;
|
||||
|
||||
-- ============================================================================
|
||||
-- Escalation Policies
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO notify.escalation_policies (id, tenant_id, name, description, enabled, steps, repeat_count)
|
||||
VALUES
|
||||
('e0000004-0000-0000-0000-000000000001', 'demo-prod', 'critical-incident', 'Escalation for critical security incidents', true,
|
||||
'[{"delay_minutes": 0, "channels": ["security-slack"], "recipients": ["security-team"]}, {"delay_minutes": 15, "channels": ["ops-email"], "recipients": ["ops-lead"]}, {"delay_minutes": 30, "channels": ["ops-email"], "recipients": ["cto"]}]'::jsonb, 2)
|
||||
ON CONFLICT (tenant_id, name) DO NOTHING;
|
||||
|
||||
-- ============================================================================
|
||||
-- Demo Incidents
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO notify.incidents (id, tenant_id, title, description, severity, status, source, correlation_id, escalation_policy_id, created_by)
|
||||
VALUES
|
||||
('e0000005-0000-0000-0000-000000000001', 'demo-prod',
|
||||
'Critical CVE-2026-10010 detected in production containers',
|
||||
'Container escape vulnerability (CVE-2026-10010) detected in containerd across 3 production hosts. Immediate patching required.',
|
||||
'critical', 'acknowledged', 'scanner', 'corr-incident-001',
|
||||
'e0000004-0000-0000-0000-000000000001', 'system'),
|
||||
('e0000005-0000-0000-0000-000000000002', 'demo-prod',
|
||||
'Feed sync failure: NVD API rate limit exceeded',
|
||||
'NVD advisory feed sync has failed 3 consecutive times due to API rate limiting. Advisory data may be stale.',
|
||||
'medium', 'open', 'scheduler', 'corr-incident-002',
|
||||
NULL, 'system'),
|
||||
('e0000005-0000-0000-0000-000000000003', 'demo-prod',
|
||||
'Policy evaluation timeout on large SBOM',
|
||||
'Policy evaluation for artifact sha256:demo_node_20 timed out after 300s due to 342 components. Consider increasing timeout or optimizing rules.',
|
||||
'low', 'resolved', 'policy-engine', 'corr-incident-003',
|
||||
NULL, 'system')
|
||||
ON CONFLICT DO NOTHING;
|
||||
Reference in New Issue
Block a user