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

108 lines
3.2 KiB
TypeScript

import { ColumnDef } from "@tanstack/react-table"
import { PaginationParams, PaginationInfo } from "./common.types"
import type { BatchCreateResponse } from "./api-response.types"
// Vulnerability related type definitions
// Vulnerability severity
export type VulnerabilitySeverity = "critical" | "high" | "medium" | "low" | "info"
// Vulnerability status
export type VulnerabilityStatus = "open" | "in_progress" | "resolved" | "false_positive" | "accepted"
// Tool raw output (JSON)
export interface VulnerabilityRawOutput {
// Dalfox fields
type?: string // R=Reflected, S=Stored
inject_type?: string // Injection type
method?: string // HTTP method
data?: string // URL
param?: string // Parameter name
payload?: string // Payload
evidence?: string // Evidence
cwe?: string // CWE
message_str?: string // Message
// Nuclei fields
"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[]
}
}
// Other fields
[key: string]: unknown
}
// Basic vulnerability type (field names match backend DRF serializer output - camelCase format)
export interface Vulnerability {
id: number
target?: number // Associated target ID
url: string // URL where vulnerability exists
vulnType: string // Vulnerability type (e.g. xss-reflected, template-id)
severity: VulnerabilitySeverity
source: string // Vulnerability source (dalfox, nuclei)
cvssScore?: number // CVSS score
description?: string // Simplified description
rawOutput?: VulnerabilityRawOutput // Tool raw output
createdAt: string // Creation time
}
// Get vulnerabilities list request parameters
export interface GetVulnerabilitiesParams extends PaginationParams {
targetId?: number
domainId?: number
endpointId?: number
severity?: VulnerabilitySeverity
status?: VulnerabilityStatus
filter?: string // Smart filter syntax
}
// Get vulnerabilities list response
export interface GetVulnerabilitiesResponse {
vulnerabilities: Vulnerability[]
total: number
page: number
pageSize: number
totalPages: number
}
// Get single vulnerability detail response
export type GetVulnerabilityByIDResponse = Vulnerability
// Vulnerability data table component props type definition
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
}
// Vulnerability batch create response
export type BatchCreateVulnerabilitiesResponse = BatchCreateResponse