Files
xingrin/frontend/types/vulnerability.types.ts
2025-12-12 18:04:57 +08:00

107 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ColumnDef } from "@tanstack/react-table"
import { PaginationParams, PaginationInfo } from "./common.types"
import type { BatchCreateResponse } from "./api-response.types"
// 漏洞相关类型定义
// 漏洞严重程度
export type VulnerabilitySeverity = "critical" | "high" | "medium" | "low" | "info"
// 漏洞状态
export type VulnerabilityStatus = "open" | "in_progress" | "resolved" | "false_positive" | "accepted"
// 工具原始输出JSON
export interface VulnerabilityRawOutput {
// Dalfox 字段
type?: string // R=Reflected, S=Stored
inject_type?: string // 注入类型
method?: string // HTTP 方法
data?: string // URL
param?: string // 参数名
payload?: string // payload
evidence?: string // 证据
cwe?: string // CWE
message_str?: string // 消息
// Nuclei 字段
"template-id"?: string
"template-path"?: string
"matched-at"?: string
host?: string
request?: string
response?: string
"curl-command"?: string
ip?: string
info?: {
name?: string
description?: string
severity?: string
tags?: string[]
reference?: string[]
classification?: {
"cve-id"?: string
"cwe-id"?: string[]
}
}
// 其他字段
[key: string]: unknown
}
// 基础漏洞类型(字段名匹配后端 DRF 序列化器输出 - 驼峰格式)
export interface Vulnerability {
id: number
target?: number // 关联的目标ID
url: string // 漏洞所在的URL
vulnType: string // 漏洞类型(如 xss-reflected, template-id
severity: VulnerabilitySeverity
source: string // 漏洞来源dalfox, nuclei
cvssScore?: number // CVSS评分
description?: string // 简化描述
rawOutput?: VulnerabilityRawOutput // 工具原始输出
discoveredAt: string // 发现时间
}
// 获取漏洞列表请求参数
export interface GetVulnerabilitiesParams extends PaginationParams {
targetId?: number
domainId?: number
endpointId?: number
severity?: VulnerabilitySeverity
status?: VulnerabilityStatus
}
// 获取漏洞列表响应
export interface GetVulnerabilitiesResponse {
vulnerabilities: Vulnerability[]
total: number
page: number
pageSize: number
totalPages: number
}
// 获取单个漏洞详情响应
export type GetVulnerabilityByIDResponse = Vulnerability
// 漏洞数据表格组件属性类型定义
export interface VulnerabilityDataTableProps {
data: Vulnerability[]
columns: ColumnDef<Vulnerability>[]
onAddNew?: () => void
onBulkDelete?: () => void
onSelectionChange?: (selectedRows: Vulnerability[]) => void
searchPlaceholder?: string
searchColumn?: string
pagination?: {
pageIndex: number
pageSize: number
}
setPagination?: (pagination: { pageIndex: number; pageSize: number }) => void
paginationInfo?: PaginationInfo
onPaginationChange?: (pagination: { pageIndex: number; pageSize: number }) => void
}
// 漏洞批量创建响应
export type BatchCreateVulnerabilitiesResponse = BatchCreateResponse