<?php

declare(strict_types=1);

namespace App\Framework\DDoS\ValueObjects;

/**
 * DDoS Attack Pattern Classification
 */
enum AttackPattern: string
{
    case VOLUMETRIC = 'volumetric';
    case PROTOCOL = 'protocol';
    case APPLICATION_LAYER = 'application_layer';
    case DISTRIBUTED = 'distributed';
    case BOTNET = 'botnet';
    case REFLECTION = 'reflection';
    case AMPLIFICATION = 'amplification';
    case SLOWLORIS = 'slowloris';

    public function getDescription(): string
    {
        return match ($this) {
            self::VOLUMETRIC => 'High volume traffic flood attack',
            self::PROTOCOL => 'Protocol-level exploitation attack',
            self::APPLICATION_LAYER => 'Application-specific targeted attack',
            self::DISTRIBUTED => 'Coordinated multi-source attack',
            self::BOTNET => 'Automated bot network attack',
            self::REFLECTION => 'Reflection-based amplification attack',
            self::AMPLIFICATION => 'Traffic amplification attack',
            self::SLOWLORIS => 'Slow connection exhaustion attack'
        };
    }

    public function getSeverityLevel(): int
    {
        return match ($this) {
            self::VOLUMETRIC => 8,
            self::DISTRIBUTED => 9,
            self::BOTNET => 7,
            self::APPLICATION_LAYER => 6,
            self::PROTOCOL => 7,
            self::REFLECTION => 8,
            self::AMPLIFICATION => 9,
            self::SLOWLORIS => 5
        };
    }

    public function getRecommendedMitigation(): array
    {
        return match ($this) {
            self::VOLUMETRIC => ['rate_limiting', 'traffic_shaping', 'upstream_filtering'],
            self::PROTOCOL => ['protocol_validation', 'connection_limits', 'stateful_inspection'],
            self::APPLICATION_LAYER => ['request_validation', 'behavior_analysis', 'captcha_challenge'],
            self::DISTRIBUTED => ['geo_blocking', 'reputation_filtering', 'challenge_response'],
            self::BOTNET => ['fingerprinting', 'behavior_analysis', 'proof_of_work'],
            self::REFLECTION => ['source_validation', 'upstream_filtering', 'protocol_hardening'],
            self::AMPLIFICATION => ['bandwidth_limiting', 'upstream_filtering', 'protocol_restrictions'],
            self::SLOWLORIS => ['connection_timeouts', 'concurrent_limits', 'keep_alive_limits']
        };
    }
}
