mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-10-30 18:13:50 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21057b1a6b | ||
|
|
136782f48e | ||
|
|
3af131272c | ||
|
|
07c0c8ee35 |
No files matched your search
+5
-1
@@ -705,7 +705,11 @@ func (d *DB) ResolveFindingReportConversation(findingID int64) (*int64, error) {
|
||||
a.detail ILIKE '%finding_id=' || $1::text || '%' OR
|
||||
a.detail ILIKE '%"finding_id":' || $1::text || '%'
|
||||
)
|
||||
ORDER BY c.updated_at DESC, c.id DESC LIMIT 1`, findingID).Scan(&id)
|
||||
ORDER BY CASE WHEN EXISTS (
|
||||
SELECT 1 FROM conversation_activities r
|
||||
WHERE r.conversation_id=c.id AND (r.tool='update_finding_report' OR r.summary ILIKE 'finding % report updated%')
|
||||
) THEN 0 ELSE 1 END,
|
||||
c.created_at ASC, c.id ASC LIMIT 1`, findingID).Scan(&id)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
+19
-17
@@ -325,15 +325,16 @@ type FindingDTO struct {
|
||||
ReportStale bool `json:"report_stale"`
|
||||
TrafficBindings []db.FindingTrafficBinding `json:"traffic_bindings,omitempty"`
|
||||
|
||||
ID string `json:"id"`
|
||||
FindingID string `json:"finding_id,omitempty"` // standalone findings-table id — the handle for status updates
|
||||
VulnClass string `json:"vulnclass"`
|
||||
Name string `json:"name,omitempty"` // 漏洞名称;为空时前端回退展示 vulnclass
|
||||
Severity string `json:"severity"` // critical | high | medium | low
|
||||
Status string `json:"status"` // pending | in_progress | confirmed | resolved | fixed | false_positive | ignored | duplicate | risk_accepted
|
||||
Summary string `json:"summary"`
|
||||
Evidence string `json:"evidence"`
|
||||
Report string `json:"report,omitempty"` // 详细报告(Markdown);仅详情接口返回,列表为空
|
||||
ID string `json:"id"`
|
||||
FindingID string `json:"finding_id,omitempty"` // standalone findings-table id — the handle for status updates
|
||||
VulnClass string `json:"vulnclass"`
|
||||
Name string `json:"name,omitempty"` // 漏洞名称;为空时前端回退展示 vulnclass
|
||||
Severity string `json:"severity"` // critical | high | medium | low
|
||||
Status string `json:"status"` // pending | in_progress | confirmed | resolved | fixed | false_positive | ignored | duplicate | risk_accepted
|
||||
Summary string `json:"summary"`
|
||||
Evidence string `json:"evidence"`
|
||||
Report string `json:"report,omitempty"` // 详细报告(Markdown);仅详情接口返回,列表为空
|
||||
ReportConversationID *int64 `json:"report_conversation_id,omitempty"`
|
||||
|
||||
IntentID string `json:"intent_id,omitempty"`
|
||||
ParamID string `json:"param_id,omitempty"`
|
||||
@@ -464,14 +465,15 @@ func findingFromDB(f *db.DBFinding, assets map[int64]*db.Asset) FindingDTO {
|
||||
FindingID: i64s(f.ID),
|
||||
TrafficCount: f.TrafficCount, EvidenceVersion: f.EvidenceVersion, ReportEvidenceVersion: f.ReportEvidenceVersion,
|
||||
ReportStale: f.Report != "" && f.EvidenceVersion != f.ReportEvidenceVersion, TrafficBindings: f.TrafficBindings,
|
||||
VulnClass: f.VulnClass,
|
||||
Name: f.Name,
|
||||
Severity: f.Severity,
|
||||
Status: status,
|
||||
Summary: f.Summary,
|
||||
Evidence: f.Evidence,
|
||||
Report: f.Report,
|
||||
TS: rfc3339(f.CreatedAt),
|
||||
VulnClass: f.VulnClass,
|
||||
Name: f.Name,
|
||||
Severity: f.Severity,
|
||||
Status: status,
|
||||
Summary: f.Summary,
|
||||
Evidence: f.Evidence,
|
||||
Report: f.Report,
|
||||
ReportConversationID: f.ReportConversationID,
|
||||
TS: rfc3339(f.CreatedAt),
|
||||
}
|
||||
if f.ExportCaseID > 0 {
|
||||
d.ID = "case:" + i64s(f.ExportCaseID)
|
||||
|
||||
@@ -51,6 +51,7 @@ export function FindingAutoChat({
|
||||
const [historyOpen, setHistoryOpen] = React.useState(false);
|
||||
const [history, setHistory] = React.useState<Conversation[]>([]);
|
||||
const cursor = React.useRef(0);
|
||||
const chatViewportRef = React.useRef<HTMLDivElement | null>(null);
|
||||
const safeTitle = findingTitle.replace(/[\[\]\r\n]/g, " ").trim().slice(0, 100);
|
||||
const storageKey = `artex.finding.${agentKey}-conversation.${findingId}`;
|
||||
|
||||
@@ -136,6 +137,18 @@ export function FindingAutoChat({
|
||||
};
|
||||
}, [conversation, open, storageKey]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!open || !conversation || loading || !messages.length) return;
|
||||
const viewport = chatViewportRef.current;
|
||||
if (!viewport) return;
|
||||
const key = `artex.conversation-scroll.${conversation.id}`;
|
||||
const saved = window.sessionStorage.getItem(key);
|
||||
requestAnimationFrame(() => {
|
||||
if (saved != null) viewport.scrollTop = Number(saved) || 0;
|
||||
else viewport.scrollTop = viewport.scrollHeight;
|
||||
});
|
||||
}, [conversation, loading, messages.length, open]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!open || !conversation || !running) return;
|
||||
let live = true;
|
||||
@@ -271,7 +284,13 @@ export function FindingAutoChat({
|
||||
<XIcon />
|
||||
</Button>
|
||||
</header>
|
||||
<div className="min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto p-3">
|
||||
<div
|
||||
ref={chatViewportRef}
|
||||
onScroll={(event) => {
|
||||
if (conversation) window.sessionStorage.setItem(`artex.conversation-scroll.${conversation.id}`, String(event.currentTarget.scrollTop));
|
||||
}}
|
||||
className="min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto p-3"
|
||||
>
|
||||
<div className="w-full min-w-0 max-w-full">
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-10 text-muted-foreground text-sm">
|
||||
|
||||
@@ -18,6 +18,8 @@ function AuthenticatedImage({
|
||||
const [captureTimestamp, setCaptureTimestamp] = React.useState<string | null>(null);
|
||||
const [zoomed, setZoomed] = React.useState(false);
|
||||
const [zoomScale, setZoomScale] = React.useState(1);
|
||||
const [pan, setPan] = React.useState({ x: 0, y: 0 });
|
||||
const dragRef = React.useRef<{ x: number; y: number; panX: number; panY: number } | null>(null);
|
||||
const imageSrc = typeof src === "string" ? src : undefined;
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -29,6 +31,7 @@ function AuthenticatedImage({
|
||||
setCaptureTimestamp(null);
|
||||
setZoomed(false);
|
||||
setZoomScale(1);
|
||||
setPan({ x: 0, y: 0 });
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
@@ -82,15 +85,36 @@ function AuthenticatedImage({
|
||||
open={zoomed}
|
||||
onOpenChange={(next) => {
|
||||
setZoomed(next);
|
||||
if (!next) setZoomScale(1);
|
||||
if (!next) {
|
||||
setZoomScale(1);
|
||||
setPan({ x: 0, y: 0 });
|
||||
}
|
||||
}}
|
||||
>
|
||||
<DialogContent
|
||||
showCloseButton
|
||||
className="flex max-h-[96dvh] max-w-[96vw] items-center justify-center overflow-hidden bg-black/85 p-3 backdrop-blur-sm sm:max-w-[96vw]"
|
||||
>
|
||||
<div className="relative flex max-h-[90dvh] max-w-full items-center justify-center overflow-auto">
|
||||
<div className="relative inline-block origin-center transition-transform duration-150" style={{ transform: `scale(${zoomScale})` }}>
|
||||
<div
|
||||
className="relative flex h-[90dvh] w-[90vw] max-w-full items-center justify-center overflow-hidden"
|
||||
onPointerDown={(event) => {
|
||||
if (zoomScale <= 1 || event.button !== 0) return;
|
||||
event.currentTarget.setPointerCapture(event.pointerId);
|
||||
dragRef.current = { x: event.clientX, y: event.clientY, panX: pan.x, panY: pan.y };
|
||||
}}
|
||||
onPointerMove={(event) => {
|
||||
const drag = dragRef.current;
|
||||
if (!drag) return;
|
||||
setPan({ x: drag.panX + event.clientX - drag.x, y: drag.panY + event.clientY - drag.y });
|
||||
}}
|
||||
onPointerUp={(event) => {
|
||||
dragRef.current = null;
|
||||
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
||||
}}
|
||||
onPointerCancel={() => { dragRef.current = null; }}
|
||||
style={{ cursor: zoomScale > 1 ? (dragRef.current ? "grabbing" : "grab") : "default" }}
|
||||
>
|
||||
<div className="relative inline-block origin-center" style={{ transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoomScale})` }}>
|
||||
<img
|
||||
src={renderedSrc}
|
||||
alt={alt || "报告截图"}
|
||||
@@ -100,6 +124,7 @@ function AuthenticatedImage({
|
||||
</div>
|
||||
</div>
|
||||
<div className="absolute top-3 left-3 z-10 flex items-center gap-1 rounded-lg bg-black/60 p-1 backdrop-blur-sm">
|
||||
<span className="px-2 text-xs font-medium text-white tabular-nums">{Math.round(zoomScale * 100)}%</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
|
||||
Reference in new issue
Block a user