fix: improve static script review and default to model judgement

This commit is contained in:
ji ruo committed 2026-10-13 14:08:00 +08:00
1 parent e47f367a7d
commit 6aa0c56d81
21 files changed
+2594 -101

No files matched your search

@@ -40,7 +40,14 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { Spinner } from "@/components/ui/spinner";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { statusMeta } from "@/lib/status";
import type { ActiveFindingRetest, Finding, FindingCaseListRow, FindingStatus, Severity } from "@/lib/types";
import type {
ActiveFindingRetest,
Finding,
FindingAsset,
FindingCaseListRow,
FindingStatus,
Severity,
} from "@/lib/types";
import { cn } from "@/lib/utils";
export const SEVERITIES: Severity[] = ["critical", "high", "medium", "low"];
@@ -275,24 +282,7 @@ export function FindingsTable({
</div>
</TableCell>
<TableCell>
{f.assets && f.assets.length > 0 ? (
<div className="flex flex-wrap gap-1">
{f.assets.slice(0, 3).map((a) => (
<code
key={a.id}
className="max-w-full truncate rounded bg-muted px-1.5 py-0.5 font-mono text-xs"
title={`${a.type} · ${a.label}`}
>
{a.label}
</code>
))}
{f.assets.length > 3 && (
<span className="text-xs text-muted-foreground">+{f.assets.length - 3}</span>
)}
</div>
) : (
<span className="text-muted-foreground">—</span>
)}
<FindingAssetLabels assets={f.assets} />
</TableCell>
<TableCell onClick={(e) => e.stopPropagation()}>
{f.finding_id ? (
@@ -511,6 +501,34 @@ export function FindingsTable({
);
}
// Ordinary reports and merged folders share one asset presentation, including
// truncation and overflow counts, so labels align in every table view.
function FindingAssetLabels({
assets = [],
totalCount = assets.length,
}: {
assets?: FindingAsset[];
totalCount?: number;
}) {
if (assets.length === 0) return <span className="text-muted-foreground">—</span>;
const visibleAssets = assets.slice(0, 3);
const remaining = Math.max(totalCount, assets.length) - visibleAssets.length;
return (
<div className="flex min-w-0 flex-wrap gap-1">
{visibleAssets.map((asset) => (
<code
key={asset.id}
className="max-w-full truncate rounded bg-muted px-1.5 py-0.5 font-mono text-xs"
title={`${asset.type} · ${asset.label}`}
>
{asset.label}
</code>
))}
{remaining > 0 ? <span className="text-xs text-muted-foreground">+{remaining}</span> : null}
</div>
);
}
// Folder summaries occupy the same columns as the current view's ordinary rows.
// Expanded members reuse those rows without a second heading or column header.
function FindingFolderTableRows({
@@ -568,18 +586,7 @@ function FindingFolderTableRows({
</div>
</TableCell>
<TableCell>
{assets.length ? (
<div className="flex flex-col gap-0.5">
{assets.slice(0, 3).map((a) => (
<code key={a.id} className="max-w-full truncate text-xs" title={`${a.type} · ${a.label}`}>
{a.label}
</code>
))}
{assetCount > 3 ? <span className="text-muted-foreground text-xs">+{assetCount - 3}</span> : null}
</div>
) : (
<span className="text-muted-foreground">—</span>
)}
<FindingAssetLabels assets={assets} totalCount={assetCount} />
</TableCell>
<TableCell>
<span className="text-muted-foreground" title="请查看成员各自的处置状态">
+3 -3
View File
@@ -203,7 +203,7 @@ const defaultJudge = (): JudgeConfig => ({
fail_action: "allow",
ask_timeout_seconds: 300,
ask_timeout_action: "deny",
incomplete_script_action: "ask",
incomplete_script_action: "model",
});
function JudgeCard() {
@@ -404,8 +404,8 @@ function JudgeCard() {
>
<SelectTrigger><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="ask">转人工审查(默认)</SelectItem>
<SelectItem value="model">继续交给模型审查</SelectItem>
<SelectItem value="ask">转人工审查</SelectItem>
<SelectItem value="model">继续交给模型审查(默认)</SelectItem>
</SelectContent>
</Select>
</Field>
+4 -3
View File
@@ -288,13 +288,14 @@ function ModelReviewContext({ input }: { input: InterceptReviewInput }) {
<div>
<h3 className="font-medium text-sm">脚本快照</h3>
<p className="text-muted-foreground text-xs">
这是审查前由平台从当前调用引用的路径读取的内容;不会在审查过程中执行脚本。
这是审查前从当前命令或引用文件提取的脚本内容;不会在审查过程中执行脚本。
</p>
</div>
{input.script_files.map((file) => (
<div key={file.path} className="flex min-w-0 flex-col gap-2 rounded-lg border p-3">
<div key={`${file.path}:${file.source ?? ""}:${file.sha256 ?? file.read_error ?? ""}`} className="flex min-w-0 flex-col gap-2 rounded-lg border p-3">
<div className="flex flex-wrap gap-x-4 gap-y-1 text-xs">
<span className="break-all font-mono">{file.path}</span>
{file.source ? <span className="text-muted-foreground">{file.source === "command" ? "命令内生成" : "引用文件"}</span> : null}
{file.sha256 ? <span className="text-muted-foreground">SHA-256 {file.sha256}</span> : null}
{file.bytes != null ? <span className="text-muted-foreground">{file.bytes} 字节</span> : null}
</div>
@@ -311,7 +312,7 @@ function ModelReviewContext({ input }: { input: InterceptReviewInput }) {
))}
{input.script_capture_status === "incomplete" ? (
<Alert variant="destructive">
<AlertDescription>无法完整读取当前执行脚本;默认转人工审查,也可以在模型设置中继续交给审查模型。</AlertDescription>
<AlertDescription>无法完整读取当前执行脚本;默认继续交给模型审查,也可以在模型设置中选择转人工审查。</AlertDescription>
</Alert>
) : null}
</section>
+1 -1
View File
@@ -2514,7 +2514,7 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
fail_action: "allow",
ask_timeout_seconds: 300,
ask_timeout_action: "deny",
incomplete_script_action: "ask",
incomplete_script_action: "model",
};
if (path === "/intercept/judge" && m === "PUT") return { ok: true };
if (path === "/intercept/judge/usage" && m === "GET")
+1
View File
@@ -1487,6 +1487,7 @@ export interface InterceptReviewInput {
script_capture_status?: "not_applicable" | "complete" | "incomplete";
script_files?: {
path: string;
source?: "file" | "command";
sha256?: string;
bytes?: number;
content?: string;