mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-04 20:41:51 +08:00
feat(findings): switch vulnerability merging to direct AI auto-merge
- Retire suggest_finding_merge tool and suggested review verdict so Reporter directly merges confirmed duplicate root causes or leaves findings independent without pending manual confirmation cards. - Add DB ListFindingIDsByTask and CreateAutoFindingCaseReviews plus auto-mode support in POST /api/exploration/finding-case-review without requiring manual finding_ids selection. - Add idempotent startup migration finding_case_tools_v4_auto_merge to refresh schemas, disable suggest_finding_merge, and obsolete legacy pending suggestions. - Remove manual suggestion cards from FindingCaseReviewPanel and replace manual selection trigger with one-click AI auto-merge on the Findings page and Task detail Findings tab. - Update README, CHANGELOG, and agent/db/server tests. Fixes #189
This commit is contained in:
1 parent
253a8eeac3
commit
257b158528
18 files changed
+636
-317
No files matched your search
@@ -12,13 +12,14 @@ import {
|
||||
InfoIcon,
|
||||
SearchIcon,
|
||||
ShieldAlertIcon,
|
||||
SparklesIcon,
|
||||
Trash2Icon,
|
||||
TriangleAlertIcon,
|
||||
} from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { FindingCaseList } from "@/components/finding-case-list";
|
||||
import { FindingCaseList, FindingCaseReviewPanel } from "@/components/finding-case-list";
|
||||
import { FindingDateFilter, type FindingDateRange } from "@/components/finding-date-filter";
|
||||
import { FindingRetestDialog } from "@/components/finding-retest-dialog";
|
||||
import { StatusBadge } from "@/components/status-badge";
|
||||
@@ -290,6 +291,7 @@ export default function FindingsPage() {
|
||||
const [cleanupScope, setCleanupScope] = React.useState<"filtered" | "all" | "selected">("all");
|
||||
const [cleaning, setCleaning] = React.useState(false);
|
||||
const [caseRefreshKey, setCaseRefreshKey] = React.useState(0);
|
||||
const [reviewRefreshKey, setReviewRefreshKey] = React.useState(0);
|
||||
|
||||
const toggleSelected = React.useCallback((id: string, checked: boolean) => {
|
||||
setSelectedIds((prev) => {
|
||||
@@ -865,6 +867,51 @@ export default function FindingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const refreshAfterAutoMerge = React.useCallback(() => {
|
||||
void refreshStats();
|
||||
if (view === "cases") {
|
||||
setCaseRefreshKey((v) => v + 1);
|
||||
} else if (view === "asset") {
|
||||
void loadFlat();
|
||||
void loadAssetTree();
|
||||
} else if (view === "flat") {
|
||||
void loadFlat();
|
||||
} else if (view === "grouped") {
|
||||
void refreshGroups();
|
||||
}
|
||||
}, [loadAssetTree, loadFlat, refreshGroups, refreshStats, view]);
|
||||
|
||||
async function doAutoMerge() {
|
||||
if (reviewing) return;
|
||||
setReviewing(true);
|
||||
try {
|
||||
const res = await api.autoMergeFindings({
|
||||
severity,
|
||||
status,
|
||||
vulnclass,
|
||||
task,
|
||||
query,
|
||||
...dateRange,
|
||||
assetScope: view === "asset" ? (assetScope ?? undefined) : undefined,
|
||||
});
|
||||
setReviewRefreshKey((v) => v + 1);
|
||||
if (res.runs.length > 0) {
|
||||
if (res.skipped_busy && res.skipped_busy > 0) {
|
||||
toast.success(
|
||||
t("findingsAutoMerge.startedWithSkipped", { count: res.runs.length, skipped: res.skipped_busy }),
|
||||
);
|
||||
} else {
|
||||
toast.success(t("findingsAutoMerge.started", { count: res.runs.length }));
|
||||
}
|
||||
} else {
|
||||
toast.info(t("findingsAutoMerge.empty"));
|
||||
}
|
||||
} catch (e) {
|
||||
toast.error(t("findingsAutoMerge.failed", { message: (e as Error).message }));
|
||||
} finally {
|
||||
setReviewing(false);
|
||||
}
|
||||
}
|
||||
const openDeepen = React.useCallback((f: Finding) => {
|
||||
setDeepenFinding(f);
|
||||
setDeepenDescription("");
|
||||
@@ -1106,23 +1153,11 @@ export default function FindingsPage() {
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={reviewing || selectedIds.size === 0}
|
||||
onClick={async () => {
|
||||
setReviewing(true);
|
||||
try {
|
||||
await api.reviewFindingCases([...selectedIds]);
|
||||
toast.success(ui("screen.25ffb72f4218ca"));
|
||||
} catch (e) {
|
||||
toast.error((e as Error).message);
|
||||
} finally {
|
||||
setReviewing(false);
|
||||
}
|
||||
}}
|
||||
disabled={reviewing || (statsLoaded && stats.total < 2)}
|
||||
onClick={doAutoMerge}
|
||||
>
|
||||
{reviewing ? <Spinner /> : null}
|
||||
{ui("screen.786fe65bb61d85")}
|
||||
{selectedIds.size}
|
||||
{ui("punctuation.f2e44c6c95")}
|
||||
{reviewing ? <Spinner /> : <SparklesIcon />}
|
||||
{reviewing ? t("findingsAutoMerge.running") : t("findingsAutoMerge.button")}
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={openExport}>
|
||||
<DownloadIcon /> {ui("screen.76420433f22d1c")}
|
||||
@@ -1139,6 +1174,12 @@ export default function FindingsPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FindingCaseReviewPanel
|
||||
taskId={task === "all" || task === UNASSIGNED_TASK ? undefined : task}
|
||||
refreshKey={reviewRefreshKey}
|
||||
onChange={refreshAfterAutoMerge}
|
||||
/>
|
||||
|
||||
{view === "flat" && flatListCard}
|
||||
|
||||
{view === "asset" && (
|
||||
@@ -1204,6 +1245,7 @@ export default function FindingsPage() {
|
||||
query={{ severity, status, vulnclass, task, query, sort, ...dateRange }}
|
||||
selectedIds={selectedIds}
|
||||
onSelect={toggleSelected}
|
||||
showReviewPanel={false}
|
||||
refreshKey={caseRefreshKey}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as React from "react";
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import { ArrowDownIcon, ArrowUpIcon, ArrowUpRightIcon, ChevronRightIcon, SearchIcon } from "lucide-react";
|
||||
import { ArrowDownIcon, ArrowUpIcon, ArrowUpRightIcon, ChevronRightIcon, SearchIcon, SparklesIcon } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import { type UITranslate, useUITranslation } from "@/i18n/use-ui-translation";
|
||||
import { api } from "@/lib/api";
|
||||
@@ -195,10 +196,32 @@ export function FindingsTab({ taskId }: { taskId: string }) {
|
||||
[t, liveUI],
|
||||
);
|
||||
|
||||
const [reviewing, setReviewing] = React.useState(false);
|
||||
const [reviewRefreshKey, setReviewRefreshKey] = React.useState(0);
|
||||
|
||||
// Discover inherited sources before filtering; finding-cases owns folder matching.
|
||||
const taskFindings = findings.filter((f) => f.task_id === taskId || f.inherited);
|
||||
const ownFindingsCount = taskFindings.filter((f) => !f.inherited).length;
|
||||
const items = filterAndSortFindings(taskFindings, severity, sortPreference, query);
|
||||
|
||||
async function doAutoMerge() {
|
||||
if (reviewing) return;
|
||||
setReviewing(true);
|
||||
try {
|
||||
const res = await api.autoMergeFindings({ task: taskId });
|
||||
setReviewRefreshKey((v) => v + 1);
|
||||
if (res.runs.length > 0) {
|
||||
toast.success(t("findingsAutoMerge.started", { count: res.runs.length }));
|
||||
} else {
|
||||
toast.info(t("findingsAutoMerge.empty"));
|
||||
}
|
||||
} catch (e) {
|
||||
toast.error(t("findingsAutoMerge.failed", { message: (e as Error).message }));
|
||||
} finally {
|
||||
setReviewing(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
@@ -284,6 +307,17 @@ export function FindingsTab({ taskId }: { taskId: string }) {
|
||||
{ui("screen.44ce7ae909bbb2")}
|
||||
</Button>
|
||||
</form>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="ml-auto"
|
||||
disabled={reviewing || ownFindingsCount < 2}
|
||||
onClick={doAutoMerge}
|
||||
>
|
||||
{reviewing ? <Spinner /> : <SparklesIcon />}
|
||||
{reviewing ? t("findingsAutoMerge.running") : t("findingsAutoMerge.button")}
|
||||
</Button>
|
||||
</div>
|
||||
<FindingCaseList
|
||||
query={{
|
||||
@@ -294,6 +328,7 @@ export function FindingsTab({ taskId }: { taskId: string }) {
|
||||
timeDirection: sortPreference.direction,
|
||||
}}
|
||||
contextTask={taskId}
|
||||
reviewRefreshKey={reviewRefreshKey}
|
||||
/>
|
||||
{[
|
||||
...new Set(
|
||||
|
||||
@@ -4,16 +4,14 @@ import * as React from "react";
|
||||
import Link from "next/link";
|
||||
|
||||
import { ChevronRightIcon, FolderIcon, FolderOpenIcon } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { StatusBadge } from "@/components/status-badge";
|
||||
import { TablePagination } from "@/components/table-pagination";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { useUITranslation } from "@/i18n/use-ui-translation";
|
||||
import { api } from "@/lib/api";
|
||||
@@ -23,7 +21,6 @@ import type {
|
||||
FindingCaseListRow,
|
||||
FindingCasePage,
|
||||
FindingCaseReviewRun,
|
||||
FindingCaseSuggestion,
|
||||
FindingQuery,
|
||||
} from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -207,107 +204,6 @@ export function FindingCaseMembers({
|
||||
);
|
||||
}
|
||||
|
||||
function FindingMergeSuggestionCard({
|
||||
suggestion: s,
|
||||
onResolve,
|
||||
}: {
|
||||
suggestion: FindingCaseSuggestion;
|
||||
onResolve: (s: FindingCaseSuggestion, accept: boolean, excludeIds?: string[]) => Promise<void>;
|
||||
}) {
|
||||
const { ui } = useUITranslation();
|
||||
|
||||
const [expanded, setExpanded] = React.useState(false);
|
||||
const [busy, setBusy] = React.useState(false);
|
||||
const ids = React.useMemo(
|
||||
() => (Array.isArray(s.finding_ids) && s.finding_ids.length > 0 ? s.finding_ids : [s.left_id, s.right_id]),
|
||||
[s.finding_ids, s.left_id, s.right_id],
|
||||
);
|
||||
const [excluded, setExcluded] = React.useState<string[]>([]);
|
||||
React.useEffect(() => {
|
||||
setExcluded((current) => {
|
||||
const next = current.filter((id) => ids.includes(id));
|
||||
return next.length === current.length ? current : next;
|
||||
});
|
||||
}, [ids]);
|
||||
const validExcluded = excluded.filter((id) => ids.includes(id));
|
||||
const included = ids.filter((id) => !validExcluded.includes(id));
|
||||
async function resolve(accept: boolean) {
|
||||
if (busy) return;
|
||||
if (accept && included.length < 2) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await onResolve(s, accept, accept ? validExcluded : []);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Card size="sm" className="min-w-0">
|
||||
<CardHeader>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="outline">
|
||||
{ui("screen.046b2f635c11ed")}
|
||||
{ids.length} {ui("screen.96a8de35964937")}
|
||||
</Badge>
|
||||
<CardDescription>
|
||||
{ui("screen.e5b1cc0dc459e5")}
|
||||
{s.task_id}
|
||||
</CardDescription>
|
||||
</div>
|
||||
<CardTitle className="break-words">{s.title}</CardTitle>
|
||||
<CardDescription className="flex flex-col gap-1">
|
||||
{ids.map((id) => (
|
||||
<span key={id} className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={!excluded.includes(id)}
|
||||
disabled={busy}
|
||||
onCheckedChange={(value) =>
|
||||
setExcluded((current) =>
|
||||
value === true
|
||||
? current.filter((item) => item !== id)
|
||||
: [...current.filter((item) => item !== id), id],
|
||||
)
|
||||
}
|
||||
aria-label={ui("screen.2ea99060e9cc28", { v0: id })}
|
||||
/>
|
||||
<Link className="underline underline-offset-4" href={`/function/findings/detail/?id=${id}`}>
|
||||
{ui("screen.9b8fd53005c92b")}
|
||||
{id}
|
||||
</Link>
|
||||
</span>
|
||||
))}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Collapsible open={expanded} onOpenChange={setExpanded}>
|
||||
{!expanded ? (
|
||||
<p className="line-clamp-2 whitespace-pre-wrap break-words text-muted-foreground text-sm">{s.reason}</p>
|
||||
) : null}
|
||||
<CollapsibleContent className="whitespace-pre-wrap break-words text-muted-foreground text-sm">
|
||||
{s.reason}
|
||||
</CollapsibleContent>
|
||||
<CollapsibleTrigger asChild>
|
||||
<Button variant="link" size="sm">
|
||||
{expanded ? ui("screen.d4585da0edd72c") : ui("screen.71717465a2f0fc")}
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
</Collapsible>
|
||||
</CardContent>
|
||||
<CardFooter className="flex flex-wrap gap-2">
|
||||
<Button variant="outline" size="sm" disabled={busy || included.length < 2} onClick={() => resolve(true)}>
|
||||
{busy ? <Spinner /> : null}
|
||||
{included.length === ids.length
|
||||
? ui("screen.09484600542d8e")
|
||||
: ui("screen.eb666ee37bde81", { v0: included.length })}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" disabled={busy} onClick={() => resolve(false)}>
|
||||
{ui("screen.04dd946ef358b7")}
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function FindingReviewRunRow({ run: r }: { run: FindingCaseReviewRun }) {
|
||||
const { ui } = useUITranslation();
|
||||
|
||||
@@ -337,38 +233,59 @@ function FindingReviewRunRow({ run: r }: { run: FindingCaseReviewRun }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function FindingCaseReviewPanel({ taskId, onChange }: { taskId?: string; onChange?: () => void }) {
|
||||
export function FindingCaseReviewPanel({
|
||||
taskId,
|
||||
onChange,
|
||||
refreshKey = 0,
|
||||
}: {
|
||||
taskId?: string;
|
||||
onChange?: () => void;
|
||||
refreshKey?: number;
|
||||
}) {
|
||||
const { ui } = useUITranslation();
|
||||
|
||||
const [suggestions, setSuggestions] = React.useState<FindingCaseSuggestion[]>([]);
|
||||
const [runs, setRuns] = React.useState<FindingCaseReviewRun[]>([]);
|
||||
const [error, setError] = React.useState("");
|
||||
const [reload, setReload] = React.useState(0);
|
||||
const requestSeq = React.useRef(0);
|
||||
const taskKey = taskId ?? "";
|
||||
const taskKeyRef = React.useRef(taskKey);
|
||||
taskKeyRef.current = taskKey;
|
||||
const previousTaskKey = React.useRef(taskKey);
|
||||
const prevActiveIdsRef = React.useRef<Set<number>>(new Set());
|
||||
const onChangeRef = React.useRef(onChange);
|
||||
onChangeRef.current = onChange;
|
||||
React.useEffect(() => {
|
||||
if (previousTaskKey.current === taskKey) return;
|
||||
previousTaskKey.current = taskKey;
|
||||
setSuggestions([]);
|
||||
prevActiveIdsRef.current = new Set();
|
||||
setRuns([]);
|
||||
setError("");
|
||||
}, [taskKey]);
|
||||
React.useEffect(() => {
|
||||
const seq = ++requestSeq.current;
|
||||
const requestedTask = taskKey;
|
||||
void reload;
|
||||
void refreshKey;
|
||||
let active = true;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
async function load() {
|
||||
try {
|
||||
const [s, r] = await Promise.all([api.findingCaseSuggestions(taskId), api.findingCaseReviewRuns()]);
|
||||
const r = await api.findingCaseReviewRuns();
|
||||
if (active && seq === requestSeq.current && requestedTask === taskKeyRef.current) {
|
||||
setSuggestions(s);
|
||||
setRuns(r.filter((x) => !taskId || x.task_id === taskId));
|
||||
const filtered = r.filter((x) => !taskId || x.task_id === taskId);
|
||||
const activeIds = new Set(
|
||||
filtered.filter((x) => x.state === "queued" || x.state === "running").map((x) => x.conversation_id),
|
||||
);
|
||||
let finishedAny = false;
|
||||
for (const id of prevActiveIdsRef.current) {
|
||||
if (!activeIds.has(id)) {
|
||||
finishedAny = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prevActiveIdsRef.current = activeIds;
|
||||
setRuns(filtered);
|
||||
setError("");
|
||||
if (finishedAny) onChangeRef.current?.();
|
||||
}
|
||||
} catch (e) {
|
||||
if (active && seq === requestSeq.current && requestedTask === taskKeyRef.current)
|
||||
@@ -383,31 +300,9 @@ export function FindingCaseReviewPanel({ taskId, onChange }: { taskId?: string;
|
||||
active = false;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [reload, taskId, taskKey]);
|
||||
async function resolve(s: FindingCaseSuggestion, accept: boolean, excludeIds?: string[]) {
|
||||
const seq = ++requestSeq.current;
|
||||
const requestedTask = taskKey;
|
||||
try {
|
||||
const result = await api.resolveFindingCaseSuggestion(s.id, accept, excludeIds);
|
||||
if (requestedTask === taskKeyRef.current) {
|
||||
setReload((v) => v + 1);
|
||||
if (seq === requestSeq.current) {
|
||||
setSuggestions((v) => v.filter((x) => x.id !== s.id));
|
||||
if (accept && result.case_id !== "0") {
|
||||
toast.success(ui("screen.f8341bc19ac543"));
|
||||
} else {
|
||||
toast.success(ui("screen.a3c1bdd20d1cf1"));
|
||||
}
|
||||
onChange?.();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (requestedTask === taskKeyRef.current) {
|
||||
setReload((v) => v + 1);
|
||||
if (seq === requestSeq.current) toast.error((e as Error).message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [refreshKey, taskId, taskKey]);
|
||||
const activeRuns = runs.filter((r) => r.state === "queued" || r.state === "running");
|
||||
if (!error && activeRuns.length === 0) return null;
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
{error ? (
|
||||
@@ -418,23 +313,11 @@ export function FindingCaseReviewPanel({ taskId, onChange }: { taskId?: string;
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
{suggestions.length > 0 ? (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{ui("screen.2ab1badc66393b")}
|
||||
{suggestions.length}
|
||||
{ui("screen.abf1d4dab0b7ab")}
|
||||
</p>
|
||||
) : null}
|
||||
{suggestions.map((s) => (
|
||||
<FindingMergeSuggestionCard key={s.id} suggestion={s} onResolve={resolve} />
|
||||
))}
|
||||
{runs.some((r) => r.state === "queued" || r.state === "running") ? (
|
||||
{activeRuns.length > 0 ? (
|
||||
<div className="flex flex-col gap-2">
|
||||
{runs
|
||||
.filter((r) => r.state === "queued" || r.state === "running")
|
||||
.map((r) => (
|
||||
<FindingReviewRunRow key={r.conversation_id} run={r} />
|
||||
))}
|
||||
{activeRuns.map((r) => (
|
||||
<FindingReviewRunRow key={r.conversation_id} run={r} />
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -447,16 +330,20 @@ export function FindingCaseList({
|
||||
onSelect,
|
||||
contextTask,
|
||||
readOnly = false,
|
||||
showReviewPanel = true,
|
||||
onTotal,
|
||||
refreshKey = 0,
|
||||
reviewRefreshKey = 0,
|
||||
}: {
|
||||
query: Omit<FindingQuery, "page" | "pageSize">;
|
||||
selectedIds?: Set<string>;
|
||||
onSelect?: (id: string, checked: boolean) => void;
|
||||
contextTask?: string;
|
||||
readOnly?: boolean;
|
||||
showReviewPanel?: boolean;
|
||||
onTotal?: (total: number) => void;
|
||||
refreshKey?: number;
|
||||
reviewRefreshKey?: number;
|
||||
}) {
|
||||
const { ui } = useUITranslation();
|
||||
|
||||
@@ -498,9 +385,10 @@ export function FindingCaseList({
|
||||
}, [data, onTotal]);
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-3">
|
||||
{!readOnly ? (
|
||||
{showReviewPanel && !readOnly ? (
|
||||
<FindingCaseReviewPanel
|
||||
taskId={query.task === "all" ? undefined : query.task}
|
||||
refreshKey={reviewRefreshKey}
|
||||
onChange={() => setRefresh((v) => v + 1)}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -233,6 +233,21 @@ export const messages = {
|
||||
"findingsCleanup.success": ["已清理 {{count}} 条漏洞", "Deleted {{count}} finding(s)"],
|
||||
"findingsCleanup.empty": ["没有符合条件的漏洞可清理", "No matching findings to delete"],
|
||||
"findingsCleanup.failed": ["清理失败:{{message}}", "Cleanup failed: {{message}}"],
|
||||
"findingsAutoMerge.button": ["AI 自动合并", "AI auto-merge"],
|
||||
"findingsAutoMerge.running": ["提交中…", "Submitting…"],
|
||||
"findingsAutoMerge.started": [
|
||||
"已启动 AI 自动合并({{count}} 个任务),将自动判断并完成合并",
|
||||
"Started AI auto-merge for {{count}} task(s); AI will judge and merge automatically",
|
||||
],
|
||||
"findingsAutoMerge.startedWithSkipped": [
|
||||
"已启动 {{count}} 个任务的 AI 自动合并,另有 {{skipped}} 个任务正在合并中",
|
||||
"Started AI auto-merge for {{count}} task(s); {{skipped}} task(s) already running",
|
||||
],
|
||||
"findingsAutoMerge.empty": [
|
||||
"没有可由 AI 自动合并的漏洞(同一任务需至少 2 条记录)",
|
||||
"No findings eligible for AI auto-merge (at least 2 findings per task required)",
|
||||
],
|
||||
"findingsAutoMerge.failed": ["启动 AI 自动合并失败:{{message}}", "Failed to start AI auto-merge: {{message}}"],
|
||||
} satisfies Record<string, readonly [string, string]>;
|
||||
|
||||
const statuses: Record<string, readonly (readonly [string, string, string])[]> = {
|
||||
|
||||
+17
-13
@@ -42,7 +42,6 @@ import type {
|
||||
FindingCaseDetail,
|
||||
FindingCasePage,
|
||||
FindingCaseReviewRun,
|
||||
FindingCaseSuggestion,
|
||||
FindingDeepenResponse,
|
||||
FindingGroupsPage,
|
||||
FindingQuery,
|
||||
@@ -866,19 +865,24 @@ export const api = {
|
||||
method: "DELETE",
|
||||
body: JSON.stringify({ reason }),
|
||||
}),
|
||||
findingCaseSuggestions: (task?: string) =>
|
||||
get<FindingCaseSuggestion[]>(
|
||||
`/exploration/finding-case-suggestions${task ? `?task_id=${encodeURIComponent(task)}` : ""}`,
|
||||
autoMergeFindings: (filters?: Omit<FindingQuery, "page" | "pageSize">) =>
|
||||
post<{ runs: { conversation_id: number; task_id: string }[]; skipped_busy?: number }>(
|
||||
"/exploration/finding-case-review",
|
||||
filters
|
||||
? {
|
||||
filters: {
|
||||
severity: filters.severity && filters.severity !== "all" ? filters.severity : undefined,
|
||||
status: filters.status && filters.status !== "all" ? filters.status : undefined,
|
||||
vulnclass: filters.vulnclass && filters.vulnclass !== "all" ? filters.vulnclass : undefined,
|
||||
task_id: filters.task && filters.task !== "all" ? filters.task : undefined,
|
||||
q: filters.query || undefined,
|
||||
from: filters.from || undefined,
|
||||
to: filters.to || undefined,
|
||||
asset_scope: filters.assetScope || undefined,
|
||||
},
|
||||
}
|
||||
: {},
|
||||
),
|
||||
resolveFindingCaseSuggestion: (id: string, accept: boolean, excludeIds?: string[]) =>
|
||||
post<{ case_id: string }>(`/exploration/finding-case-suggestions/${id}`, {
|
||||
accept,
|
||||
...(excludeIds && excludeIds.length > 0 ? { exclude_ids: excludeIds } : {}),
|
||||
}),
|
||||
reviewFindingCases: (ids: string[]) =>
|
||||
post<{ runs: { conversation_id: number; task_id: string }[] }>("/exploration/finding-case-review", {
|
||||
finding_ids: ids,
|
||||
}),
|
||||
regenerateFindingCase: (id: string, contextTask?: string) =>
|
||||
post<{ runs: { conversation_id: number; task_id: string }[] }>(
|
||||
`/exploration/finding-case-review${contextTask ? `?context_task=${encodeURIComponent(contextTask)}` : ""}`,
|
||||
|
||||
@@ -2087,7 +2087,7 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
if (path === "/exploration/finding-case-suggestions" || (path === "/exploration/finding-case-review" && m === "GET"))
|
||||
return [];
|
||||
if (path === "/exploration/finding-case-review" && m === "POST")
|
||||
throw new Error("演示模式不执行 Reporter 整理,请在已配置模型的实例中使用");
|
||||
throw new Error("演示模式不执行 AI 自动合并,请在已配置模型的实例中使用");
|
||||
if (path === "/exploration/finding-cases" && m === "GET") {
|
||||
const list = filterAndSortFindings(mockApplyAssetScope(mockFilterFindings(q), q.get("asset_scope")), "all", {
|
||||
field: q.get("sort") === "severity" ? "severity" : "time",
|
||||
|
||||
@@ -1861,16 +1861,6 @@ export interface FindingCaseDetail {
|
||||
case: FindingCase;
|
||||
events: FindingCaseEvent[];
|
||||
}
|
||||
export interface FindingCaseSuggestion {
|
||||
id: string;
|
||||
task_id: string;
|
||||
left_id: string;
|
||||
right_id: string;
|
||||
finding_ids: string[];
|
||||
title: string;
|
||||
reason: string;
|
||||
state: string;
|
||||
}
|
||||
export interface FindingCaseReviewRun {
|
||||
conversation_id: number;
|
||||
task_id: string;
|
||||
|
||||
Reference in new issue
Block a user