use crate::error::CoreError;
use crate::models::dast::{DastFinding, DastTarget};

/// Context passed to DAST agents containing discovered information
#[derive(Debug, Clone, Default)]
pub struct DastContext {
    /// Discovered endpoints from crawling
    pub endpoints: Vec<DiscoveredEndpoint>,
    /// Technologies detected during recon
    pub technologies: Vec<String>,
    /// Existing SAST findings for prioritization
    pub sast_hints: Vec<String>,
}

/// An endpoint discovered during crawling
#[derive(Debug, Clone)]
pub struct DiscoveredEndpoint {
    pub url: String,
    pub method: String,
    pub parameters: Vec<EndpointParameter>,
    pub content_type: Option<String>,
    pub requires_auth: bool,
}

/// A parameter on a discovered endpoint
#[derive(Debug, Clone)]
pub struct EndpointParameter {
    pub name: String,
    /// "query", "body", "header", "path", "cookie"
    pub location: String,
    pub param_type: Option<String>,
    pub example_value: Option<String>,
}

/// Trait for DAST testing agents (injection, XSS, auth bypass, etc.)
#[allow(async_fn_in_trait)]
pub trait DastAgent: Send + Sync {
    /// Agent name (e.g., "sql_injection", "xss", "auth_bypass")
    fn name(&self) -> &str;

    /// Run the agent against a target with discovered context
    async fn run(
        &self,
        target: &DastTarget,
        context: &DastContext,
    ) -> Result<Vec<DastFinding>, CoreError>;
}
