-- Migration für WAF-Feedback Tabelle
-- Führe diese SQL-Datei aus um die Tabelle zu erstellen

CREATE TABLE IF NOT EXISTS waf_feedback (
    id INT PRIMARY KEY AUTO_INCREMENT,

    -- Feedback-Identifikation
    detection_id VARCHAR(255) NOT NULL,
    feedback_type VARCHAR(50) NOT NULL,

    -- Benutzer-Informationen
    user_id VARCHAR(255) NOT NULL,
    comment TEXT NULL,

    -- Kategorisierung
    category VARCHAR(100) NOT NULL,
    severity VARCHAR(50) NOT NULL,

    -- Zusätzliche Daten
    context JSON NULL,

    -- System-Felder
    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    processed BOOLEAN DEFAULT FALSE,
    processed_at TIMESTAMP NULL,

    -- Indizes
    INDEX idx_detection_id (detection_id),
    INDEX idx_feedback_type (feedback_type),
    INDEX idx_category (category),
    INDEX idx_severity (severity),
    INDEX idx_timestamp (timestamp),
    INDEX idx_processed (processed)
);

-- Beispiel-Daten einfügen (optional)
INSERT INTO waf_feedback (detection_id, feedback_type, user_id, comment, category, severity, context) VALUES
('d123e456-789a-bcde-f012-3456789abcde', 'false_positive', 'admin', 'This is a legitimate request from our partner API', 'SQL_INJECTION', 'HIGH', '{"request_ip": "192.168.1.100", "url": "/api/data"}'),
('d234e567-89ab-cdef-0123-456789abcdef', 'correct_detection', 'admin', 'Confirmed attack attempt', 'XSS', 'CRITICAL', '{"request_ip": "203.0.113.42", "url": "/search"}');
