mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-06-06 06:13:58 +02:00
Add files via upload
This commit is contained in:
@@ -720,7 +720,7 @@ async function loadVulnerabilityStats() {
|
||||
throw new Error('apiFetch未定义');
|
||||
}
|
||||
|
||||
const params = buildVulnerabilityFilterParams();
|
||||
const params = buildVulnerabilityDashboardStatsParams();
|
||||
|
||||
const response = await apiFetch(`/api/vulnerabilities/stats?${params.toString()}`);
|
||||
if (!response.ok) {
|
||||
@@ -1531,6 +1531,13 @@ function buildVulnerabilityFilterParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/** 看板统计:保留项目/关键词等筛选,但不带严重度(卡片本身用于切换严重度筛选) */
|
||||
function buildVulnerabilityDashboardStatsParams() {
|
||||
const params = buildVulnerabilityFilterParams();
|
||||
params.delete('severity');
|
||||
return params;
|
||||
}
|
||||
|
||||
function triggerTextDownload(fileName, content) {
|
||||
const blob = new Blob([content], { type: 'text/markdown;charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
@@ -1543,6 +1550,53 @@ function triggerTextDownload(fileName, content) {
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function hasActiveVulnerabilityFilters() {
|
||||
const keys = ['q', 'id', 'project_id', 'conversation_id', 'task_id', 'conversation_tag', 'task_tag', 'severity', 'status'];
|
||||
return keys.some(function (k) {
|
||||
return Boolean(vulnerabilityFilters[k]);
|
||||
});
|
||||
}
|
||||
|
||||
async function batchDeleteVulnerabilityReports() {
|
||||
try {
|
||||
const params = buildVulnerabilityFilterParams();
|
||||
const statsResponse = await apiFetch(`/api/vulnerabilities/stats?${params.toString()}`);
|
||||
if (!statsResponse.ok) {
|
||||
throw new Error(vulnT('vulnerabilityPage.deleteFailed'));
|
||||
}
|
||||
const stats = await statsResponse.json();
|
||||
const count = stats.total || 0;
|
||||
if (count <= 0) {
|
||||
alert(vulnT('vulnerabilityPage.batchDeleteNoResults'));
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmKey = hasActiveVulnerabilityFilters()
|
||||
? 'vulnerabilityPage.batchDeleteConfirm'
|
||||
: 'vulnerabilityPage.batchDeleteConfirmAll';
|
||||
if (!confirm(vulnT(confirmKey, { count: count }))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await apiFetch(`/api/vulnerabilities/batch?${params.toString()}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ error: vulnT('vulnerabilityPage.deleteFailed') }));
|
||||
throw new Error(error.error || vulnT('vulnerabilityPage.deleteFailed'));
|
||||
}
|
||||
const data = await response.json();
|
||||
const deleted = data.deleted || 0;
|
||||
alert(vulnT('vulnerabilityPage.batchDeleteSuccess', { count: deleted }));
|
||||
vulnerabilityPagination.currentPage = 1;
|
||||
loadVulnerabilityStats();
|
||||
loadVulnerabilities();
|
||||
} catch (error) {
|
||||
console.error('批量删除漏洞失败:', error);
|
||||
alert(vulnT('vulnerabilityPage.batchDeleteFailed') + ': ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function exportVulnerabilityReports() {
|
||||
try {
|
||||
const params = buildVulnerabilityFilterParams();
|
||||
|
||||
Reference in New Issue
Block a user