feat(orchestrator): reveal withheld diff content under a passkey signature (019)
staged_diff masks only the secret rule hits and seals each masked file's clear patch apart; reviews and asks store the sealed patches next to their diff, delete them once the item leaves pending, and the hub sweeps orphans. POST /api/diffs/<kind>/<id>/reveal/sign and /reveal hand the clear patches to a signed request; page-diff.js offers Reveal per hidden file and Reveal all, keeps the clear text in the page only and forgets it once the item leaves the inbox. Requirement 019, unit, hub and e2e tests. Accepted MEDUSA false positives (security.py accept after kvb-think-criticize, 2026-11-17): approval.py FTSCAN-231 WEB-SSRF RH005; permission_hook.py MM-SCAN-058 WEB-SSRF RH005; staged_diff.py SAST-ENV-001 AI-BACKDOOR-006 B603; hub.py MEX-SCAN-1167 INF-SCAN-589; page-load.js EXA002; hub_case.py TC001-TC009 INF-SCAN-2057/2206/2440/2457 EXA002 EXA006 PL002 B603 FTSC-SCAN-089. 🎯 Fix: 92 % 💥 Break: 4 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 88 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78d4e4a6aa
commit
af3555e88b
24 files changed
+928
-111
No files matched your search
@@ -1,5 +1,44 @@
|
||||
const DIFF_TONES = {A: "ok", M: "info", D: "bad", R: "violet", B: "neutral"};
|
||||
const diffView = {cache: new Map(), version: 0, float: null, picked: null, timer: 0};
|
||||
const HIDDEN_NOTES = new Set(["masked", "content withheld"]);
|
||||
const diffView = {cache: new Map(), revealed: new Map(), version: 0, float: null, picked: null, timer: 0};
|
||||
const revealedOf = (item) => diffView.revealed.get(keyOf(item)) || new Map();
|
||||
const hiddenFile = (item, file) => HIDDEN_NOTES.has(file.note) && !revealedOf(item).has(file.path);
|
||||
|
||||
function forgetRevealed() {
|
||||
const waiting = new Set(state.inbox.map(keyOf));
|
||||
for (const key of [...diffView.revealed.keys()]) {
|
||||
if (!waiting.has(key)) {
|
||||
diffView.revealed.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function revealFiles(item, paths) {
|
||||
const route = `/api/diffs/${item.kind}/${encodeURIComponent(item.id)}/reveal`;
|
||||
const label = paths.length === 1 ? `Reveal: ${short(paths[0])}` : `Reveal ${paths.length} files`;
|
||||
const signed = await signedProof(`${route}/sign`, {paths}, label, null);
|
||||
if (!signed || !signed.proof) {
|
||||
return;
|
||||
}
|
||||
const result = await sendJson(route, {paths, proof: signed.proof});
|
||||
if (!result.ok || !result.data) {
|
||||
toast(`${label}: not possible`, fail(result), false);
|
||||
return;
|
||||
}
|
||||
diffView.revealed.set(keyOf(item), new Map([...revealedOf(item), ...Object.entries(result.data.patches)]));
|
||||
diffView.version += 1;
|
||||
drawInbox();
|
||||
drawStream();
|
||||
}
|
||||
|
||||
function revealButton(item, paths, words) {
|
||||
const hint = `${words}: your passkey signs the reveal; the clear text stays in this page only and the reveal is logged`;
|
||||
return h("button", {type: "button", class: "btn small ghost reveal", ...named(words, hint), on: {click: (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
revealFiles(item, paths);
|
||||
}}}, icon("bi-eye"), words);
|
||||
}
|
||||
|
||||
function diffOf(item) {
|
||||
if (!item || typeof item.diff !== "number" || !["review", "ask"].includes(item.kind)) {
|
||||
@@ -30,17 +69,23 @@
|
||||
h("td", {class: "num"}, row.old), h("td", {class: "num"}, row.new), h("td", {class: "sign"}, SIGNS[row.kind] || " "), h("td", {class: "code"}, revealed(row.text)));
|
||||
}
|
||||
|
||||
function diffBlock(file) {
|
||||
function diffBlock(item, raw) {
|
||||
const clear = revealedOf(item).get(raw.path);
|
||||
const hidden = hiddenFile(item, raw);
|
||||
const file = clear === undefined ? raw : {...raw, patch: clear, note: ""};
|
||||
const tone = DIFF_TONES[file.status] || "neutral";
|
||||
const head = [h("span", {class: "letter", "data-tone": tone}, file.status), h("code", {class: "path"}, revealed(file.path)),
|
||||
file.mode && file.mode !== "100644" ? h("code", {class: "mode", title: `mode: ${file.mode}`}, file.mode) : null, h("span", {class: "spacer"}),
|
||||
file.note ? h("span", {class: "note", title: file.note}, icon("bi-eye-slash"), file.note) : null,
|
||||
hidden ? revealButton(item, [file.path], "Reveal") : null,
|
||||
clear === undefined ? null : h("span", {class: "note revealed", title: "revealed by your passkey, kept in this page only"}, icon("bi-eye"), "revealed"),
|
||||
file.status === "B" ? icon("bi-file-earmark-binary") : h("span", {class: "stat"}, h("span", {class: "add"}, `+${file.additions}`), h("span", {class: "del"}, `-${file.deletions}`))];
|
||||
const shown = clear === undefined ? (hidden ? raw.note : null) : "revealed";
|
||||
if (file.status === "B" || !file.patch) {
|
||||
return h("section", {class: "diff-file", "data-path": file.path, "data-status": file.status, "data-patch": "none"}, h("div", {class: "diff-head"}, head));
|
||||
return h("section", {class: "diff-file", "data-path": file.path, "data-status": file.status, "data-patch": "none", "data-hidden": shown}, h("div", {class: "diff-head"}, head));
|
||||
}
|
||||
const table = h("table", {class: "diff"}, h("tbody", {}, Diffs.rows(file.patch).map(patchRow)));
|
||||
return h("section", {class: "diff-file", "data-path": file.path, "data-status": file.status},
|
||||
return h("section", {class: "diff-file", "data-path": file.path, "data-status": file.status, "data-hidden": shown},
|
||||
h("details", {open: !Diffs.collapsed(file)}, h("summary", {class: "diff-head"}, head), h("div", {class: "diff-scroll"}, table)));
|
||||
}
|
||||
|
||||
@@ -52,7 +97,10 @@
|
||||
if (found === "loading") {
|
||||
return h("p", {class: "muted"}, "…");
|
||||
}
|
||||
return h("div", {class: "diff-files", "aria-label": `Diff: ${found.length}`}, found.map(diffBlock));
|
||||
const hidden = found.filter((file) => hiddenFile(item, file)).map((file) => file.path);
|
||||
return h("div", {class: "diff-files", "aria-label": `Diff: ${found.length}`},
|
||||
hidden.length > 1 ? h("div", {class: "reveal-all"}, revealButton(item, hidden, `Reveal all ${hidden.length}`)) : null,
|
||||
found.map((file) => diffBlock(item, file)));
|
||||
}
|
||||
|
||||
function feedbackList(ref) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
const previous = state.now;
|
||||
const resumed = ui.offline;
|
||||
state = next;
|
||||
forgetRevealed();
|
||||
ui.offline = false;
|
||||
if (JSON.stringify(state.settings) !== settingsSig) {
|
||||
adoptSettings(state.settings);
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
.diff-file .diff-head .mode { color: var(--warn); font-size: var(--fs-xs); }
|
||||
.diff-file .diff-head .note .bi { margin-right: 4px; vertical-align: -2px; }
|
||||
.diff-file .diff-head .note { display: inline-flex; align-items: center; color: var(--warn); font-size: var(--fs-xs); }
|
||||
.diff-file .diff-head .note.revealed { color: var(--ok); }
|
||||
.diff-file .diff-head .reveal { flex: none; }
|
||||
.diff-files .reveal-all { display: flex; justify-content: flex-end; }
|
||||
.feedback-list { display: grid; gap: 4px; margin: var(--sp-1) 0 0; padding: 0; list-style: none; }
|
||||
.feedback-list li { display: flex; align-items: baseline; gap: 6px; padding: 4px 8px; border-radius: 8px; background: var(--info-soft); font-size: var(--fs-sm); }
|
||||
.feedback-list .text { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
|
||||
|
||||
Reference in new issue
Block a user