Requirement 001 S6: the hub gets a Firewall view of the Claude Code permission and sandbox settings. The operator signs each change with the passkey; a host settings writer (systemd path unit) applies only exact, signed changes to allowlisted settings files through O_NOFOLLOW directory and file descriptors, and a timer refreshes the view. Every signed text and every page sink refuses or marks hidden characters: Cc, Cf, Zl, Zp, every space but U+0020 and the Default_Ignorable set, with U+FE0E/U+FE0F allowed only after one of the 359 non-ASCII emoji bases of Unicode 16 (shared table, validated at import, the same pair rule on the page). Removal of a deny, ask or denyRead entry is exempt only as an exact single remove. The permission hook prints the hub's refusal reason, cleaned of hidden characters. Accepted MEDUSA false positives (independent review, operator pick): 38 this round, mainly the Unicode defence tables read as attack patterns, generic MM-SCAN-058 heuristics, WEB-FLASK-004 at view.py:213 (ints from the validated table via tojson), EXF26-TOOL-004 on the non-secret WebAuthn challenge, PRIV-SCAN-060 on the office-action shape check and PQC007 on a picker key. 🎯 Fix: 95 % 💥 Break: 3 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 92 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
4.7 KiB
JavaScript
85 lines
4.7 KiB
JavaScript
const CLEANUP_POLL = 2000;
|
|
const CLEANUP_PATIENCE = 900000;
|
|
const RESULT_LABELS = {done: ["deleted", "ok"], refused: ["refused", "bad"], failed: ["failed", "bad"]};
|
|
|
|
function planOf(item) {
|
|
const repo = (tree.data.repos || []).find((entry) => entry.path === item.repository);
|
|
const entry = repo ? repo.branches.find((candidate) => candidate.name === item.branch) : null;
|
|
return {repo, entry};
|
|
}
|
|
|
|
function deleteDialog(items, locked = [], held = []) {
|
|
if (!items.length) {
|
|
return;
|
|
}
|
|
const rows = [...items, ...locked, ...held].map((item) => {
|
|
const {repo, entry} = planOf(item);
|
|
const waits = locked.includes(item);
|
|
const kept = held.includes(item);
|
|
return h("li", {class: waits ? "dry-run locked" : kept ? "dry-run held" : "dry-run", "data-token": waits ? "needed" : null, "data-held": kept && entry ? entry.held : null},
|
|
h("div", {class: "row"}, h("strong", {}, revealed(repo ? repo.name : item.repository)), h("code", {}, revealed(item.branch)), waits ? pill("token needed", "warn") : kept ? pill("held by a worktree: not deleted here", "neutral") : null),
|
|
h("pre", {}, (entry ? entry.plan : [`${item.branch} @ ${item.tip.slice(0, 12)}`]).map(revealed).join("\n")));
|
|
});
|
|
const outcome = h("div", {class: "mini", "aria-live": "polite"});
|
|
const confirm = h("button", {type: "button", class: "btn danger", ...named("Delete", "Delete: hand over to the host with your passkey signature")}, icon("bi-trash3"), "Delete");
|
|
confirm.addEventListener("click", async () => {
|
|
confirm.disabled = true;
|
|
if (!await removeSigned(items, outcome)) {
|
|
confirm.disabled = false;
|
|
}
|
|
});
|
|
openSheet(items.length > 1 ? `Delete ${items.length} merged branches` : `Delete ${items[0].branch}`, [
|
|
h("p", {class: "muted"}, "Dry run of pkgmgr branch cleanup for exactly these entries: it deletes the local branch and never touches a worktree, Compose stack or volume. No remote branch: the host refuses an entry whose plan deletes one. A branch held by a worktree is not deleted here: branch gc (kvb-git-gc, pkgmgr gc) removes it, and its docker compose down -v deletes the stack's volumes. The host checks your signature and refuses every entry whose state has changed since."),
|
|
h("ul", {class: "mini", "aria-label": "Dry run"}, rows),
|
|
outcome,
|
|
h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm),
|
|
], false);
|
|
}
|
|
|
|
async function removeSigned(items, outcome) {
|
|
const signed = await proofFor(items, "Delete");
|
|
if (signed === null) {
|
|
outcome.replaceChildren(h("p", {class: "muted"}, "Not signed: nothing was handed over."));
|
|
return false;
|
|
}
|
|
const result = await sendJson("/api/cleanup", {items, proof: signed.proof});
|
|
if (!result.ok || !result.data) {
|
|
toast("Delete: not possible", fail(result), false);
|
|
outcome.replaceChildren(h("p", {class: "muted"}, `${result.status} ${result.text}`.trim()));
|
|
return false;
|
|
}
|
|
outcome.replaceChildren(h("p", {class: "muted", "data-cleanup": result.data.id}, `Signed and handed to the host (job ${result.data.id}); the path unit deletes now.`));
|
|
followJob(`/api/cleanup/${encodeURIComponent(result.data.id)}`, outcome, Date.now(), (data) => {
|
|
const {good, lines} = showJob(data, outcome, "branch", RESULT_LABELS);
|
|
toast(`Delete: ${good ? "done" : "not everything deleted"}`, lines, good);
|
|
fetchTree();
|
|
});
|
|
return true;
|
|
}
|
|
|
|
async function followJob(url, outcome, began, finish) {
|
|
let data = null;
|
|
try {
|
|
const response = await fetch(url, {cache: "no-store"});
|
|
data = response.ok ? await response.json() : null;
|
|
} catch {
|
|
data = null;
|
|
}
|
|
if (!data || data.status !== "done") {
|
|
if (Date.now() - began < CLEANUP_PATIENCE && outcome.isConnected) {
|
|
window.setTimeout(() => followJob(url, outcome, began, finish), CLEANUP_POLL);
|
|
}
|
|
return;
|
|
}
|
|
finish(data);
|
|
}
|
|
|
|
function showJob(data, outcome, key, labels) {
|
|
const lines = data.error ? [data.error] : data.items.map((item) => `${item[key]}: ${(labels[item.status] || [item.status])[0]}${item.reason ? ` (${item.reason})` : ""}`);
|
|
outcome.replaceChildren(h("ul", {class: "mini", "aria-label": "Result"}, data.error ? h("li", {}, data.error) : data.items.map((item) => {
|
|
const [label, tone] = labels[item.status] || [item.status, "neutral"];
|
|
return h("li", {"data-result": item.status}, h("div", {class: "row"}, h("code", {}, item[key]), pill(label, tone)), item.reason ? h("span", {class: "muted"}, item.reason) : null);
|
|
})));
|
|
return {good: !data.error && data.items.every((item) => item.status === "done"), lines};
|
|
}
|