Intercept: always allow a pending Bash prefix (argv allow rule, code-owned denylist)

POST /api/intercept/pending/{id}/always-allow derives an argv allow rule from the stored pending row (never from the body), at priority -1000, reusing an identical enabled rule, and leaves the request pending. A code-owned denylist of interpreters, launchers, package managers, orchestration and destructive programs refuses such rules at creation, in the manual rule form, and neutralises argv allow rules at matching; argv deny and ask rules still match.
This commit is contained in:
BaaRai
2026-11-13 11:24:25 +01:00
parent e2fd4908f7
commit 62e65f1235
10 changed files with 501 additions and 3 deletions
+35
View File
@@ -297,6 +297,38 @@ function DecisionActions({ row, busy, decide }: { row: InterceptApprovalRow; bus
);
}
// AlwaysAllowAction creates an argv allow rule from a pending Bash request.
// The prefix comes from the server; the request itself stays pending.
function AlwaysAllowAction({ id, prefix }: { id: number; prefix?: string }) {
const [busy, setBusy] = React.useState(false);
async function create() {
setBusy(true);
try {
const res = await api.interceptAlwaysAllow(id);
toast.success(
res.created
? "Rule created, the request is still pending approval"
: "Rule already exists, the request is still pending approval",
);
} catch (e) {
toast.error((e as Error).message);
} finally {
setBusy(false);
}
}
return (
<div className="flex flex-col gap-1">
<Button size="sm" variant="outline" className="self-start" disabled={busy} onClick={() => void create()}>
{prefix ? `Toujours autoriser "${prefix} *"` : "Toujours autoriser"}
</Button>
<p className="text-muted-foreground text-xs">
The prefix does not constrain flags, and it does not cover what the program does next (git hooks, npm
scripts, docker images).
</p>
</div>
);
}
export function ApprovalDetail({
row,
busy,
@@ -418,6 +450,9 @@ export function ApprovalDetail({
) : null}
</dl>
{!readOnly ? <DecisionActions row={current} busy={busy} decide={decide} /> : null}
{!readOnly && current.status === "pending" && row.tool_name === "Bash" ? (
<AlwaysAllowAction id={row.id} prefix={detail?.always_allow_prefix} />
) : null}
</div>
</div>
{error ? (
+3
View File
@@ -1232,6 +1232,9 @@ export const api = {
interceptGetOne: (id: number) => get<InterceptPending>(`/intercept/pending/${id}`),
interceptDecide: (id: number, decision: "allowed" | "denied") =>
post<{ ok: boolean }>(`/intercept/pending/${id}/decide`, { decision }),
// No body: the server derives the rule from the stored request, which stays pending.
interceptAlwaysAllow: (id: number) =>
post<{ rule: InterceptRule; created: boolean }>(`/intercept/pending/${id}/always-allow`),
interceptExecution: (id: number, conversationId?: number) =>
get<import("@/lib/types").InterceptExecution>(
`/intercept/history/${id}/execution${conversationId ? `?conversation=${conversationId}` : ""}`,
+1
View File
@@ -1560,6 +1560,7 @@ export interface InterceptAudit {
}
export interface InterceptDetail extends InterceptApprovalRow {
audit: InterceptAudit | null;
always_allow_prefix?: string; // pending Bash request: the argv prefix "always allow" would allow
}
export type TrafficEvidenceRole = "baseline" | "proof" | "verification" | "supporting";