/**
 * 安全测试相关类型定义
 *
 * @author czj
 * @date 2026-07-21
 */

/**
 * 安全测试配置
 */
export interface SecurityConfig {
  id: string
  name: string
  targetUrl: string
  serverIp: string
  verifySsl: boolean
  timeout: number
  accounts: Record<string, any>
  authConfig: Record<string, any>
  rateLimits: Record<string, any>
  apiPrefixes: Record<string, any>
  isDefault: boolean
  description: string
  createdAt?: string
  updatedAt?: string
}

/**
 * 创建/更新安全测试配置
 */
export interface SecurityConfigFormData {
  name: string
  targetUrl: string
  serverIp?: string
  verifySsl?: boolean
  timeout?: number
  accounts?: Record<string, any>
  authConfig?: Record<string, any>
  rateLimits?: Record<string, any>
  apiPrefixes?: Record<string, any>
  isDefault?: boolean
  description?: string
}

/**
 * 漏洞测试结果
 */
export interface VulnerabilityResult {
  id: string
  executionId: string
  caseId: string
  testId: string
  name: string
  level: 'critical' | 'high' | 'medium' | 'low' | 'info'
  description: string
  requestInfo: string
  responseInfo: string
  isVulnerable: boolean
  fixSuggestion: string
  duration: number
  status: string
  errorMessage?: string
  extraData: Record<string, any>
  createdAt?: string
}

/**
 * 安全测试执行创建参数
 */
export interface SecurityExecutionCreate {
  configId: string
  moduleIds?: string[]
  caseIds?: string[]
  includeRegression?: boolean
  includeRedline?: boolean
  name?: string
}

/**
 * 安全测试执行响应
 */
export interface SecurityExecutionResponse {
  id: string
  name: string
  status: string
  totalCases: number
  passed: number
  failed: number
  skipped: number
  duration: number
  configId: string
  startTime?: string
  endTime?: string
}

/**
 * 历史漏洞条目
 */
export interface HistoricalVuln {
  vulnId: string
  title: string
  severity: string
  vulnType: string
  sourceProject: string
  detectionMethod: string
  regressionNote: string
  mappedPaths: string[]
}

/**
 * 华为安全红线检查项
 */
export interface HuaweiRedlineCheck {
  checkId: string
  category: string
  requirement: string
  severity: string
  checkMethod: string
}

/**
 * 知识库响应
 */
export interface KnowledgeBaseResponse {
  historicalVulns: HistoricalVuln[]
  huaweiRedlines: HuaweiRedlineCheck[]
  totalVulns: number
  totalRedlines: number
}

/**
 * 账号测试结果
 */
export interface AccountTestResponse {
  accountKey: string
  success: boolean
  tokenPreview: string
  errorMessage: string
}

/**
 * 执行摘要
 */
export interface ExecutionSummary {
  executionId: string
  levelStats: Record<string, { total: number; vulnerable: number }>
}
