@broberg/lens-daemon 0.1.55 → 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/flow.ts +3 -1
- package/src/inspect-redact.ts +55 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@broberg/lens-daemon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"description": "The Lens module of the cardmem daemon (flows, critic, coverage, capture sessions, the /lens/* routes and the cardmem-lens MCP) as a package. The daemon mounts createLensRouter(deps) + createLensMcpRouter(deps). Bun runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/flow.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { takeBrowserRepairs, withPage, type LensEngine, type RunBrowser } from '
|
|
|
27
27
|
import { takeChromeClonesRemoved } from './chrome-clones.ts';
|
|
28
28
|
import { collectNetworkShapes, type NetworkShapesOptions, type NetworkShapesReport } from './network-shapes.ts';
|
|
29
29
|
import { passkeysUnavailableInPage, virtualPasskeys, VIRTUAL_PASSKEYS_NEED_CHROMIUM } from './passkeys.ts';
|
|
30
|
+
import { redactInspect } from './inspect-redact.ts';
|
|
30
31
|
import { deadline, defaultPopupOf, prepareExtension, seedExtensionStorage, SIMULATED_ACCESS_NOTE } from './extension-flow.ts';
|
|
31
32
|
import { authPrepare, fetchMintJson, persistStorageState, persistTarget, type AuthConfig, type AuthEnv } from './auth/index.ts';
|
|
32
33
|
import { takeShot, settleForShot } from './capture.ts';
|
|
@@ -3088,7 +3089,8 @@ export async function runFlow(flow: Flow, env: AuthEnv, opts: RunFlowOptions = {
|
|
|
3088
3089
|
? await expectRequest(step, vars)
|
|
3089
3090
|
: await execStep(sp, step, base, vars, opts.critic ?? 'off', opts.localPath, sink, filledPasswords, notListening, opts.secretRoot, mailCtx);
|
|
3090
3091
|
const obj = out !== null && !Buffer.isBuffer(out) && typeof out === 'object' ? out : null;
|
|
3091
|
-
|
|
3092
|
+
// F010.14 — never a password in the report, whatever the page keeps in its attributes.
|
|
3093
|
+
const inspect = obj && '__inspect' in obj ? redactInspect((obj as { __inspect: string }).__inspect, filledPasswords) : null;
|
|
3092
3094
|
const via = obj && '__via' in obj ? (obj as { __via: string }).__via : null;
|
|
3093
3095
|
// F074.30 — a waitForBuild step KNOWS the live sha; it wins over the
|
|
3094
3096
|
// best-effort read taken before driving.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// lens F010.14 — an inspect report never carries a password.
|
|
2
|
+
//
|
|
3
|
+
// jam (#44821, run 13f7f1b5): Google keeps what was typed into its password field in
|
|
4
|
+
// the attribute data-initial-value, and `inspect` copied the field's outerHTML into
|
|
5
|
+
// the run report — the owner's Google password stood there in plain text. A password
|
|
6
|
+
// input masks itself on screen; its attributes do not.
|
|
7
|
+
//
|
|
8
|
+
// Applied to every inspect result before it reaches the report, on the server, so it
|
|
9
|
+
// holds for both forms (the anchor dump and `html:true`) whatever the page does:
|
|
10
|
+
// 1. a password-like <input> loses its value and every data-* attribute but
|
|
11
|
+
// data-testid (the anchor an author needs);
|
|
12
|
+
// 2. an <input> tag the 400-char cut left unterminated is treated the same — its
|
|
13
|
+
// type may be the part that was cut away;
|
|
14
|
+
// 3. every value Lens itself typed from a secret (vault / file, or a typed password)
|
|
15
|
+
// is replaced wherever it appears, whatever attribute or text holds it.
|
|
16
|
+
import type { FilledPassword } from './password-in-url.ts';
|
|
17
|
+
|
|
18
|
+
export const REDACTED = '[redacted]';
|
|
19
|
+
|
|
20
|
+
const SECRET_INPUT = /\btype\s*=\s*"password"|\bautocomplete\s*=\s*"[^"]*(?:password|one-time-code)[^"]*"/i;
|
|
21
|
+
const VALUE_ATTRS = /\s(?:value|data-(?!testid\b)[\w.:-]+)\s*=\s*"[^"]*"?/gi;
|
|
22
|
+
|
|
23
|
+
function scrubHtml(html: string): string {
|
|
24
|
+
return html.replace(/<input\b[^>]*(?:>|$)/gi, (tag) =>
|
|
25
|
+
SECRET_INPUT.test(tag) || !tag.endsWith('>') ? tag.replace(VALUE_ATTRS, '') : tag,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function redactInspect(raw: string, filled: readonly FilledPassword[]): string {
|
|
30
|
+
let out = raw;
|
|
31
|
+
try {
|
|
32
|
+
const dump = JSON.parse(raw) as Record<string, unknown>;
|
|
33
|
+
if (dump && typeof dump === 'object' && ('inputs' in dump || 'clickables' in dump)) {
|
|
34
|
+
for (const key of ['inputs', 'clickables'] as const) {
|
|
35
|
+
const list = dump[key];
|
|
36
|
+
if (!Array.isArray(list)) continue;
|
|
37
|
+
for (const e of list as Array<{ html?: unknown }>) if (typeof e.html === 'string') e.html = scrubHtml(e.html);
|
|
38
|
+
}
|
|
39
|
+
out = JSON.stringify(dump);
|
|
40
|
+
} else out = scrubHtml(raw);
|
|
41
|
+
} catch {
|
|
42
|
+
out = scrubHtml(raw);
|
|
43
|
+
}
|
|
44
|
+
for (const { value } of filled) {
|
|
45
|
+
if (value.length < 4) continue; // a 1–3 character value would blank half the page
|
|
46
|
+
// The same secret in every spelling a report can hold it: raw, as the browser
|
|
47
|
+
// serialises it into an attribute (& → & — measured: a password with & was
|
|
48
|
+
// missed), and each of those inside a JSON string.
|
|
49
|
+
const html = value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/\u00a0/g, ' ');
|
|
50
|
+
for (const form of new Set([value, html, JSON.stringify(value).slice(1, -1), JSON.stringify(html).slice(1, -1)])) {
|
|
51
|
+
out = out.split(form).join(REDACTED);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|