mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-03 20:21:51 +08:00
feat: improve finding reports and evidence exports
This commit is contained in:
1 parent
fb672389b0
commit
b0a29236f8
14 files changed
+485
-45
No files matched your search
@@ -144,6 +144,7 @@ function FindingDetailInner() {
|
||||
<SideQuestionWorkspace
|
||||
side={side}
|
||||
label={`漏洞 #${finding.id} · ${title}`}
|
||||
mode="floating"
|
||||
suggestions={["请解释这个漏洞的影响范围和利用条件。", "请根据当前证据检查这个漏洞是否足以确认。", "请给出可执行的修复建议。"]}
|
||||
placeholder="询问当前漏洞…"
|
||||
>
|
||||
|
||||
@@ -787,6 +787,11 @@ function GraphInner({ taskId, coverageEnabled = true }: { taskId: string; covera
|
||||
graph = new Graph({
|
||||
container: containerRef.current,
|
||||
autoResize: true,
|
||||
// Keep wheel/trackpad zoom within a readable range. Very small zoom
|
||||
// values make labels and the fixed network zones appear to collapse
|
||||
// into a single strip; an upper bound also prevents focusElement from
|
||||
// pushing the selected node underneath the overlay panel.
|
||||
zoomRange: [0.35, 3],
|
||||
// Asset mode explicitly centers after rendering. Network mode keeps
|
||||
// its fixed world coordinates so the three background zones align.
|
||||
background: "transparent",
|
||||
@@ -824,6 +829,7 @@ function GraphInner({ taskId, coverageEnabled = true }: { taskId: string; covera
|
||||
behaviors: ["drag-element", "drag-canvas", "zoom-canvas"],
|
||||
});
|
||||
graph.on("aftertransform", syncViewport);
|
||||
graph.on("afterresize", syncViewport);
|
||||
graph.on("node:click", (evt: unknown) => {
|
||||
const id = (evt as { target?: { id?: string } }).target?.id;
|
||||
if (!id) return;
|
||||
@@ -861,7 +867,7 @@ function GraphInner({ taskId, coverageEnabled = true }: { taskId: string; covera
|
||||
graph?.destroy();
|
||||
graphRef.current = null;
|
||||
};
|
||||
}, [applyData, syncViewport]);
|
||||
}, [applyData, resetView, syncViewport]);
|
||||
|
||||
// 可见集合变化 → 重新灌数据 + 布局。sig 只作为重排触发器(applyData 读 gDataRef)。
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: sig 是刻意的重排触发依赖
|
||||
@@ -1075,7 +1081,7 @@ function GraphInner({ taskId, coverageEnabled = true }: { taskId: string; covera
|
||||
className="h-7 px-2 text-xs"
|
||||
onClick={() => {
|
||||
setActivePath([]);
|
||||
void graphRef.current?.fitCenter();
|
||||
void resetView();
|
||||
}}
|
||||
>
|
||||
清除高亮
|
||||
|
||||
@@ -38,6 +38,7 @@ export default function SystemSettingsPage() {
|
||||
const [savingIntelligence, setSavingIntelligence] = React.useState(false);
|
||||
const [trafficCapture, setTrafficCapture] = React.useState(false);
|
||||
const [browserScreenshot, setBrowserScreenshot] = React.useState(false);
|
||||
const [browserScreenshotTimestamp, setBrowserScreenshotTimestamp] = React.useState(false);
|
||||
const [agentTrafficBinding, setAgentTrafficBinding] = React.useState(false);
|
||||
const [webSearch, setWebSearch] = React.useState(false);
|
||||
const [backend, setBackend] = React.useState("ddgs");
|
||||
@@ -96,6 +97,7 @@ export default function SystemSettingsPage() {
|
||||
setChatAutoTitleEnabled(!!s.chat_auto_title_enabled);
|
||||
setTrafficCapture(!!s.traffic_capture);
|
||||
setBrowserScreenshot(!!s.browser_screenshot_enabled);
|
||||
setBrowserScreenshotTimestamp(!!s.browser_screenshot_timestamp_enabled);
|
||||
setAgentTrafficBinding(!!s.agent_traffic_binding);
|
||||
setWebSearch(!!s.web_search_enabled);
|
||||
setBackend(s.web_search_backend || "ddgs");
|
||||
@@ -239,6 +241,22 @@ export default function SystemSettingsPage() {
|
||||
.finally(() => setSaving(false));
|
||||
};
|
||||
|
||||
const toggleBrowserScreenshotTimestamp = (v: boolean) => {
|
||||
setBrowserScreenshotTimestamp(v);
|
||||
setSaving(true);
|
||||
api
|
||||
.setSettings({ browser_screenshot_timestamp_enabled: v })
|
||||
.then((s) => {
|
||||
apply(s);
|
||||
toast.success(v ? "已开启截图时间标记" : "已关闭截图时间标记");
|
||||
})
|
||||
.catch((e) => {
|
||||
setBrowserScreenshotTimestamp(!v);
|
||||
toast.error(`保存失败:${(e as Error).message}`);
|
||||
})
|
||||
.finally(() => setSaving(false));
|
||||
};
|
||||
|
||||
const toggleInjectPlanner = (v: boolean) => {
|
||||
setInjectPlanner(v); // optimistic
|
||||
api
|
||||
@@ -493,6 +511,29 @@ export default function SystemSettingsPage() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="mb-4 break-inside-avoid md:mb-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-base">
|
||||
<CameraIcon className="size-4" />
|
||||
截图时间标记
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
开启后,报告中的浏览器截图会在右上角显示截图保存时间,格式为“年月日 时:分:秒”(例如 2026-10-29 01:14:11)。该标记只影响截图展示,不改变原始截图文件。
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex items-center justify-between gap-4">
|
||||
<Label htmlFor="browser-screenshot-timestamp" className="text-sm font-normal text-muted-foreground">
|
||||
{browserScreenshotTimestamp ? "已开启 · 显示截图时间" : "已关闭 · 使用原始截图"}
|
||||
</Label>
|
||||
<Switch
|
||||
id="browser-screenshot-timestamp"
|
||||
checked={browserScreenshotTimestamp}
|
||||
disabled={!loaded || saving}
|
||||
onCheckedChange={toggleBrowserScreenshotTimestamp}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="mb-4 break-inside-avoid md:mb-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-base">
|
||||
|
||||
@@ -208,7 +208,9 @@ export function FindingReproductionPanel({ finding, contextTask }: { finding: Fi
|
||||
[finding.evidence, finding.report, finding.summary],
|
||||
);
|
||||
const [traffic, setTraffic] = React.useState<FindingTrafficBinding[] | undefined>(undefined);
|
||||
const overview = reportSection(finding.report ?? "", ["概述", "影响与危害", "受影响范围"]);
|
||||
const overviewSections = ["概述", "影响与危害", "受影响范围"]
|
||||
.map((heading) => ({ heading, content: reportSection(finding.report ?? "", [heading]) }))
|
||||
.filter((item) => item.content);
|
||||
const outcome = reportSection(finding.report ?? "", ["最终结果"]);
|
||||
const rootCause = reportSection(finding.report ?? "", ["根因分析"]);
|
||||
const remediation = reportSection(finding.report ?? "", ["修复建议"]);
|
||||
@@ -242,11 +244,11 @@ export function FindingReproductionPanel({ finding, contextTask }: { finding: Fi
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
{overview ? (
|
||||
<div className="rounded-lg bg-muted/30 px-3 py-2.5 text-sm">
|
||||
<Markdown text={overview} />
|
||||
{overviewSections.map((section) => (
|
||||
<div key={section.heading} className="rounded-lg bg-muted/30 px-3 py-2.5 text-sm">
|
||||
<Markdown text={`## ${section.heading}\n\n${section.content}`} />
|
||||
</div>
|
||||
) : null}
|
||||
))}
|
||||
{steps.map((step, index) => {
|
||||
const binding = traffic?.find((item) => item.position === index) ?? traffic?.[index];
|
||||
return (
|
||||
|
||||
@@ -1,9 +1,70 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import ReactMarkdown, { type Components } from "react-markdown";
|
||||
import ReactMarkdown, { defaultUrlTransform, type Components } from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
import { auth } from "@/lib/auth";
|
||||
|
||||
function AuthenticatedImage({
|
||||
src,
|
||||
alt,
|
||||
...props
|
||||
}: React.ImgHTMLAttributes<HTMLImageElement>) {
|
||||
const [objectURL, setObjectURL] = React.useState<string | null>(null);
|
||||
const [captureTimestamp, setCaptureTimestamp] = React.useState<string | null>(null);
|
||||
const imageSrc = typeof src === "string" ? src : undefined;
|
||||
|
||||
React.useEffect(() => {
|
||||
let cancelled = false;
|
||||
let url: string | null = null;
|
||||
|
||||
if (!imageSrc || !imageSrc.startsWith("/api/workspace/preview")) {
|
||||
setObjectURL(null);
|
||||
setCaptureTimestamp(null);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}
|
||||
|
||||
const token = auth.getToken();
|
||||
setCaptureTimestamp(null);
|
||||
fetch(imageSrc, {
|
||||
credentials: "same-origin",
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error(`图片读取失败: ${response.status}`);
|
||||
setCaptureTimestamp(response.headers.get("X-Report-Screenshot-Timestamp"));
|
||||
return response.blob();
|
||||
})
|
||||
.then((blob) => {
|
||||
if (cancelled) return;
|
||||
url = URL.createObjectURL(blob);
|
||||
setObjectURL(url);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setObjectURL(null);
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
if (url) URL.revokeObjectURL(url);
|
||||
};
|
||||
}, [imageSrc]);
|
||||
|
||||
return (
|
||||
<span className="relative my-2 inline-block max-w-full">
|
||||
<img {...props} src={objectURL ?? imageSrc} alt={alt || "报告截图"} />
|
||||
{captureTimestamp && (
|
||||
<span className="pointer-events-none absolute right-2 top-2 rounded bg-black/70 px-2 py-1 font-mono text-[11px] text-white shadow">
|
||||
{captureTimestamp}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// Tailwind-styled element overrides (no typography plugin in this project, so we
|
||||
// style each element). `node` is stripped — it's not a valid DOM attribute.
|
||||
const components: Components = {
|
||||
@@ -22,14 +83,20 @@ const components: Components = {
|
||||
const resolvedSrc =
|
||||
typeof src === "string" && src.startsWith("workspace://")
|
||||
? `/api/workspace/preview?path=${encodeURIComponent(src.slice("workspace://".length))}`
|
||||
: typeof src === "string" && src.startsWith("findings/screenshots/")
|
||||
? `/api/workspace/preview?path=${encodeURIComponent(src)}`
|
||||
: src;
|
||||
return (
|
||||
<img
|
||||
<AuthenticatedImage
|
||||
{...p}
|
||||
className="my-2 max-h-[520px] max-w-full rounded-md border object-contain"
|
||||
src={resolvedSrc}
|
||||
alt={alt || "报告截图"}
|
||||
loading="lazy"
|
||||
{...p}
|
||||
// Report screenshots are evidence and must be fetched while the report is
|
||||
// rendered; Edge may replace lazy images with placeholders indefinitely
|
||||
// when the markdown section is outside the initial viewport.
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
/>
|
||||
);
|
||||
},
|
||||
@@ -64,7 +131,13 @@ const components: Components = {
|
||||
export function Markdown({ text }: { text: string }) {
|
||||
return (
|
||||
<div className="min-w-0 space-y-1.5 text-sm [&>*:first-child]:mt-0">
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]} components={components}>
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={components}
|
||||
urlTransform={(url) =>
|
||||
url.startsWith("workspace://") || url.startsWith("findings/screenshots/") ? url : defaultUrlTransform(url)
|
||||
}
|
||||
>
|
||||
{text}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
|
||||
@@ -248,6 +248,7 @@ export function SideQuestionWorkspace({
|
||||
side,
|
||||
label,
|
||||
children,
|
||||
mode = "split",
|
||||
composerLayout = "stacked",
|
||||
suggestions,
|
||||
placeholder,
|
||||
@@ -257,6 +258,7 @@ export function SideQuestionWorkspace({
|
||||
side: SideQuestions;
|
||||
label: string;
|
||||
children: ReactNode;
|
||||
mode?: "split" | "floating";
|
||||
composerLayout?: ComposerLayout;
|
||||
suggestions?: string[];
|
||||
placeholder?: string;
|
||||
@@ -265,9 +267,25 @@ export function SideQuestionWorkspace({
|
||||
}) {
|
||||
const mobile = useIsMobile();
|
||||
const desktopSideOpen = side.open && side.enabled && !mobile;
|
||||
const floatingSideOpen = desktopSideOpen && mode === "floating";
|
||||
return (
|
||||
<>
|
||||
{desktopSideOpen ? (
|
||||
{floatingSideOpen ? (
|
||||
<>
|
||||
<div className={cn("min-h-0 min-w-0 flex-1", className, mainClassName)}>{children}</div>
|
||||
<div className="pointer-events-none fixed inset-x-0 top-20 z-40 flex justify-end px-4 pb-4 sm:px-6">
|
||||
<div className="pointer-events-auto h-[calc(100svh-6rem)] w-[min(420px,calc(100vw-2rem))] overflow-hidden rounded-xl border bg-background shadow-2xl">
|
||||
<SidePanel
|
||||
side={side}
|
||||
label={label}
|
||||
composerLayout={composerLayout}
|
||||
suggestions={suggestions}
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : desktopSideOpen ? (
|
||||
<ResizablePanelGroup orientation="horizontal" className={cn("min-h-0 min-w-0 flex-1", className)}>
|
||||
<ResizablePanel
|
||||
id="main-conversation"
|
||||
|
||||
@@ -972,6 +972,8 @@ export interface Settings {
|
||||
traffic_capture: boolean;
|
||||
/** 是否向可见 Agent 暴露浏览器 MCP 的截图工具。默认关闭。 */
|
||||
browser_screenshot_enabled?: boolean;
|
||||
/** 是否在报告截图右上角显示截图保存时间。默认关闭。 */
|
||||
browser_screenshot_timestamp_enabled?: boolean;
|
||||
credential_agent_enabled: boolean;
|
||||
credential_traffic_binding: boolean;
|
||||
task_intelligence_enabled: boolean; // 默认关闭;关闭不注入情报工具或提示
|
||||
|
||||
Reference in new issue
Block a user