// =============================================================================
// Resilience and Recovery Controls
// Categories: RESILIENCE, RECOVERY
// =============================================================================

import { ControlLibraryEntry } from '../../types'

export const RESILIENCE_RECOVERY_CONTROLS: ControlLibraryEntry[] = [
  // RESILIENCE
  {
    id: 'TOM-RE-01',
    code: 'TOM-RE-01',
    category: 'RESILIENCE',
    type: 'TECHNICAL',
    name: { de: 'Load Balancing', en: 'Load Balancing' },
    description: {
      de: 'Implementierung von Lastverteilung zur Sicherstellung der Systemstabilitaet bei hoher Last.',
      en: 'Implementation of load balancing to ensure system stability under high load.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. b' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.17.2.1' },
    ],
    applicabilityConditions: [
      { field: 'riskProfile.ciaAssessment.availability', operator: 'GREATER_THAN', value: 3, result: 'REQUIRED', priority: 20 },
      { field: 'dataProfile.dataVolume', operator: 'IN', value: ['HIGH', 'VERY_HIGH'], result: 'RECOMMENDED', priority: 15 },
    ],
    defaultApplicability: 'OPTIONAL',
    evidenceRequirements: ['Load-Balancer-Konfiguration', 'Kapazitaetsplanung'],
    reviewFrequency: 'QUARTERLY',
    priority: 'MEDIUM',
    complexity: 'MEDIUM',
    tags: ['resilience', 'load-balancing'],
  },
  {
    id: 'TOM-RE-02',
    code: 'TOM-RE-02',
    category: 'RESILIENCE',
    type: 'TECHNICAL',
    name: { de: 'DDoS-Schutz', en: 'DDoS Protection' },
    description: {
      de: 'Massnahmen zum Schutz vor Distributed Denial of Service Angriffen.',
      en: 'Measures to protect against Distributed Denial of Service attacks.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. b' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.13.1.1' },
    ],
    applicabilityConditions: [
      { field: 'architectureProfile.hostingModel', operator: 'IN', value: ['PUBLIC_CLOUD', 'HYBRID'], result: 'RECOMMENDED', priority: 15 },
      { field: 'riskProfile.protectionLevel', operator: 'EQUALS', value: 'VERY_HIGH', result: 'REQUIRED', priority: 25 },
    ],
    defaultApplicability: 'RECOMMENDED',
    evidenceRequirements: ['DDoS-Schutzkonzept', 'WAF-Konfiguration'],
    reviewFrequency: 'QUARTERLY',
    priority: 'HIGH',
    complexity: 'MEDIUM',
    tags: ['security', 'ddos'],
  },
  {
    id: 'TOM-RE-03',
    code: 'TOM-RE-03',
    category: 'RESILIENCE',
    type: 'TECHNICAL',
    name: { de: 'Auto-Scaling', en: 'Auto-Scaling' },
    description: {
      de: 'Automatische Skalierung von Ressourcen basierend auf der tatsaechlichen Last.',
      en: 'Automatic scaling of resources based on actual load.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. b' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.12.1.3' },
    ],
    applicabilityConditions: [
      { field: 'architectureProfile.hostingModel', operator: 'IN', value: ['PUBLIC_CLOUD', 'HYBRID'], result: 'RECOMMENDED', priority: 15 },
    ],
    defaultApplicability: 'OPTIONAL',
    evidenceRequirements: ['Auto-Scaling-Konfiguration', 'Kapazitaetsmetriken'],
    reviewFrequency: 'QUARTERLY',
    priority: 'MEDIUM',
    complexity: 'MEDIUM',
    tags: ['cloud', 'scaling'],
  },
  {
    id: 'TOM-RE-04',
    code: 'TOM-RE-04',
    category: 'RESILIENCE',
    type: 'TECHNICAL',
    name: { de: 'DDoS-Abwehr (erweitert)', en: 'DDoS Mitigation (Advanced)' },
    description: {
      de: 'Erweiterte DDoS-Schutzmassnahmen inkl. Traffic-Analyse, automatischer Mitigation und Incident-Response-Integration.',
      en: 'Advanced DDoS protection measures including traffic analysis, automatic mitigation and incident response integration.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. b' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.13.1.1' },
    ],
    applicabilityConditions: [
      { field: 'riskProfile.protectionLevel', operator: 'EQUALS', value: 'VERY_HIGH', result: 'REQUIRED', priority: 25 },
      { field: 'architectureProfile.hostingModel', operator: 'IN', value: ['PUBLIC_CLOUD', 'HYBRID'], result: 'RECOMMENDED', priority: 15 },
    ],
    defaultApplicability: 'OPTIONAL',
    evidenceRequirements: ['DDoS-Schutzkonzept (erweitert)', 'Mitigation-Berichte', 'Incident-Playbooks'],
    reviewFrequency: 'QUARTERLY',
    priority: 'HIGH',
    complexity: 'HIGH',
    tags: ['resilience', 'ddos', 'advanced'],
  },
  {
    id: 'TOM-RE-05',
    code: 'TOM-RE-05',
    category: 'RESILIENCE',
    type: 'ORGANIZATIONAL',
    name: { de: 'Kapazitaetsplanung', en: 'Capacity Planning' },
    description: {
      de: 'Systematische Planung und Ueberwachung von IT-Kapazitaeten zur Sicherstellung der Systemverfuegbarkeit bei wachsender Nutzung.',
      en: 'Systematic planning and monitoring of IT capacities to ensure system availability with growing usage.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. b' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.12.1.3' },
    ],
    applicabilityConditions: [
      { field: 'dataProfile.dataVolume', operator: 'IN', value: ['HIGH', 'VERY_HIGH'], result: 'REQUIRED', priority: 20 },
    ],
    defaultApplicability: 'RECOMMENDED',
    evidenceRequirements: ['Kapazitaetsplan', 'Trend-Analysen', 'Skalierungskonzept'],
    reviewFrequency: 'QUARTERLY',
    priority: 'MEDIUM',
    complexity: 'MEDIUM',
    tags: ['resilience', 'capacity', 'planning'],
  },

  // RECOVERY
  {
    id: 'TOM-RC-01',
    code: 'TOM-RC-01',
    category: 'RECOVERY',
    type: 'TECHNICAL',
    name: { de: 'Disaster Recovery Plan', en: 'Disaster Recovery Plan' },
    description: {
      de: 'Dokumentierter und getesteter Plan zur Wiederherstellung von IT-Systemen nach einem Katastrophenfall.',
      en: 'Documented and tested plan for restoring IT systems after a disaster.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. c' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.17.1.2' },
    ],
    applicabilityConditions: [
      { field: 'riskProfile.ciaAssessment.availability', operator: 'GREATER_THAN', value: 2, result: 'REQUIRED', priority: 20 },
    ],
    defaultApplicability: 'REQUIRED',
    evidenceRequirements: ['Disaster-Recovery-Plan', 'Test-Protokolle', 'RTO/RPO-Definitionen'],
    reviewFrequency: 'ANNUAL',
    priority: 'CRITICAL',
    complexity: 'HIGH',
    tags: ['disaster-recovery', 'bcp'],
  },
  {
    id: 'TOM-RC-02',
    code: 'TOM-RC-02',
    category: 'RECOVERY',
    type: 'TECHNICAL',
    name: { de: 'Geo-Redundanz', en: 'Geo-Redundancy' },
    description: {
      de: 'Geografisch verteilte Datenhaltung zur Sicherstellung der Verfuegbarkeit bei regionalen Ausfaellen.',
      en: 'Geographically distributed data storage to ensure availability during regional outages.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. c' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.17.2.1' },
    ],
    applicabilityConditions: [
      { field: 'riskProfile.protectionLevel', operator: 'EQUALS', value: 'VERY_HIGH', result: 'REQUIRED', priority: 30 },
      { field: 'riskProfile.ciaAssessment.availability', operator: 'GREATER_THAN', value: 4, result: 'REQUIRED', priority: 25 },
    ],
    defaultApplicability: 'OPTIONAL',
    evidenceRequirements: ['Geo-Redundanz-Konzept', 'Standort-Dokumentation'],
    reviewFrequency: 'ANNUAL',
    priority: 'HIGH',
    complexity: 'HIGH',
    tags: ['geo-redundancy', 'availability'],
  },
  {
    id: 'TOM-RC-03',
    code: 'TOM-RC-03',
    category: 'RECOVERY',
    type: 'ORGANIZATIONAL',
    name: { de: 'Wiederherstellungstests', en: 'Recovery Testing' },
    description: {
      de: 'Regelmaessige Tests der Wiederherstellungsverfahren zur Validierung der Backup- und DR-Strategie.',
      en: 'Regular testing of recovery procedures to validate backup and DR strategy.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. d' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.17.1.3' },
    ],
    applicabilityConditions: [],
    defaultApplicability: 'REQUIRED',
    evidenceRequirements: ['Test-Protokolle', 'Wiederherstellungszeiten', 'Massnahmenplan bei Fehlern'],
    reviewFrequency: 'SEMI_ANNUAL',
    priority: 'HIGH',
    complexity: 'MEDIUM',
    tags: ['testing', 'recovery'],
  },
  {
    id: 'TOM-RC-04',
    code: 'TOM-RC-04',
    category: 'RECOVERY',
    type: 'TECHNICAL',
    name: { de: 'Georedundantes Backup', en: 'Geo-Redundant Backup' },
    description: {
      de: 'Speicherung von Backup-Kopien an geografisch getrennten Standorten zum Schutz vor standortbezogenen Katastrophen.',
      en: 'Storage of backup copies at geographically separated locations to protect against site-specific disasters.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. c' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.12.3.1' },
      { framework: 'BSI_IT_GRUNDSCHUTZ', reference: 'CON.3' },
    ],
    applicabilityConditions: [
      { field: 'riskProfile.protectionLevel', operator: 'IN', value: ['HIGH', 'VERY_HIGH'], result: 'REQUIRED', priority: 25 },
      { field: 'riskProfile.ciaAssessment.availability', operator: 'GREATER_THAN', value: 3, result: 'REQUIRED', priority: 20 },
    ],
    defaultApplicability: 'RECOMMENDED',
    evidenceRequirements: ['Georedundanz-Konzept', 'Backup-Standort-Dokumentation', 'Wiederherstellungstests'],
    reviewFrequency: 'SEMI_ANNUAL',
    priority: 'HIGH',
    complexity: 'HIGH',
    tags: ['recovery', 'backup', 'geo-redundancy'],
  },
  {
    id: 'TOM-RC-05',
    code: 'TOM-RC-05',
    category: 'RECOVERY',
    type: 'ORGANIZATIONAL',
    name: { de: 'Notfallwiederherstellungs-Tests', en: 'Disaster Recovery Testing' },
    description: {
      de: 'Regelmaessige Durchfuehrung und Dokumentation von Notfallwiederherstellungstests zur Validierung der RTO/RPO-Ziele.',
      en: 'Regular execution and documentation of disaster recovery tests to validate RTO/RPO targets.',
    },
    mappings: [
      { framework: 'GDPR_ART32', reference: 'Art. 32 Abs. 1 lit. c, d' },
      { framework: 'ISO27001_ANNEX_A', reference: 'A.17.1.3' },
    ],
    applicabilityConditions: [
      { field: 'securityProfile.hasDRPlan', operator: 'EQUALS', value: true, result: 'REQUIRED', priority: 25 },
    ],
    defaultApplicability: 'RECOMMENDED',
    evidenceRequirements: ['DR-Testberichte', 'RTO/RPO-Messungen', 'Verbesserungsmassnahmen'],
    reviewFrequency: 'SEMI_ANNUAL',
    priority: 'HIGH',
    complexity: 'MEDIUM',
    tags: ['recovery', 'dr-testing', 'rto', 'rpo'],
  },
]
