"""
NeuroSploit v3 - Vulnerability Schemas
"""
from datetime import datetime
from typing import Optional, List
from pydantic import BaseModel


class VulnerabilityTestResponse(BaseModel):
    """Schema for vulnerability test response"""
    id: str
    scan_id: str
    endpoint_id: Optional[str]
    vulnerability_type: str
    payload: Optional[str]
    request_data: dict
    response_data: dict
    is_vulnerable: bool
    confidence: Optional[float]
    evidence: Optional[str]
    tested_at: datetime

    class Config:
        from_attributes = True


class VulnerabilityResponse(BaseModel):
    """Schema for vulnerability response"""
    id: str
    scan_id: str
    test_id: Optional[str]
    title: str
    vulnerability_type: str
    severity: str
    cvss_score: Optional[float]
    cvss_vector: Optional[str]
    cwe_id: Optional[str]
    description: Optional[str]
    affected_endpoint: Optional[str]
    poc_request: Optional[str]
    poc_response: Optional[str]
    poc_payload: Optional[str]
    impact: Optional[str]
    remediation: Optional[str]
    references: List
    ai_analysis: Optional[str]
    created_at: datetime

    class Config:
        from_attributes = True


class VulnerabilityTypeInfo(BaseModel):
    """Information about a vulnerability type"""
    type: str
    name: str
    category: str
    description: str
    severity_range: str  # "medium-critical"
    owasp_category: Optional[str] = None
    cwe_ids: List[str] = []


class VulnerabilitySummary(BaseModel):
    """Summary of vulnerabilities for dashboard"""
    total: int = 0
    critical: int = 0
    high: int = 0
    medium: int = 0
    low: int = 0
    info: int = 0
    by_type: dict = {}
