Skip to content

Commit a7d6f8e

Browse files
fix(server): keep sensitive values out of settings reads, startup logs and preview snapshots
Settings: the OpenCode server password is now marked as a secret setting. It is stored in the secret store instead of settings.json (existing plain-text values migrate on the next load), and settings reads, updates, config snapshots and settingsUpdated events return the redaction marker. isSecretSetting also treats any password-control form field as secret. Settings forms get a clear button for saved secret fields, and the Antigravity guide no longer says its API key is stored in plain text. Startup logs: the web-mode pairing URL, which carries a one-time admin token, is printed straight to stdout instead of going through the structured logger, so it no longer reaches the trace file or OTLP log export. The browser auto-open for that URL runs with tracing disabled so failed-launch spans do not record it, and the fallback hint points at the printed URL instead of repeating it. Preview snapshots: preview_snapshot reads the values of password fields (and text fields drawn as dots by CSS) from an isolated world in each frame, and masks those values wherever the accessibility tree and visibleText print them, keeping roles and refs intact. The capture fails rather than returning a tree it cannot vouch for, and finishes within 10s including one retry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f5cb328 commit a7d6f8e

11 files changed

Lines changed: 523 additions & 43 deletions

File tree

‎apps/server/src/preview/ServerBrowser.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ function makeSession(frame?: ReturnType<typeof makeFrame>) {
8080
if (method === "Page.getLayoutMetrics") return { cssVisualViewport: { pageX: 0, pageY: 0 } };
8181
if (method === "Page.captureScreenshot") return { data: "ZnJhbWU=" };
8282
if (method === "Page.getFrameTree") return { frameTree: { frame: { id: "main" } } };
83-
if (method === "Page.createIsolatedWorld") return { executionContextId: 7 };
83+
// Snapshots read password fields from their own isolated world in each frame.
84+
if (method === "Page.createIsolatedWorld") {
85+
return {
86+
executionContextId: (input as { worldName?: string }).worldName === "t3-preview" ? 1 : 7,
87+
};
88+
}
89+
if (method === "Runtime.evaluate" && (input as { contextId?: number }).contextId === 1) {
90+
return { result: { value: [] } };
91+
}
8492
if (method === "Page.addScriptToEvaluateOnNewDocument") frame?.recording.resolve();
8593
if (method === "Input.dispatchKeyEvent" && (input as { commands?: unknown }).commands) {
8694
if (focusedFrame) focusedFrame.copy = keyCopy || focusedFrame.copy;

‎apps/server/src/preview/ServerBrowserPage.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,38 @@ describe("server browser element refs", () => {
124124
expect(await page.getByRole("textbox", { name: "parent" }).inputValue()).toBe("");
125125
});
126126

127+
it("shows dotted fields as dots wherever their value appears, keeping text values and refs", async () => {
128+
await page.setContent(`
129+
<table><tr><td>password:</td><td><input id="pw" type="password" aria-label="Password"></td></tr></table>
130+
<input aria-label="Username" value="maria">
131+
<input type="password" aria-label='saved" [ref=e2]: x' placeholder="hint" value="saved-pass">
132+
<input type="password" role="combobox" aria-label="Code" value="role-pass">
133+
<input aria-label="PIN" style="-webkit-text-security: disc" value="styled-pass">
134+
<iframe srcdoc="<input type=password aria-label=child value=frame-pass>"></iframe>
135+
<iframe id="blank" src="javascript:false"></iframe>
136+
<p>Order styled-pass-2</p>
137+
<script>
138+
// A frame that never commits a document, filled by its parent.
139+
blank.contentDocument.body.innerHTML = "<input type=password aria-label=blank value=blank-pass>";
140+
// Page script can't change the value the snapshot sees.
141+
Object.defineProperty(HTMLInputElement.prototype, "value", { get: () => "" });
142+
</script>`);
143+
await page.frameLocator("iframe[srcdoc]").getByRole("textbox").waitFor();
144+
await ServerBrowserPage.type(page, { locator: "#pw", text: "typed-pass" });
145+
const result = await takeSnapshot();
146+
const tree = String(result.accessibilityTree);
147+
expect(tree).toContain('textbox "blank"');
148+
expect(tree).not.toMatch(/typed-pass|saved-pass|role-pass|styled-pass|frame-pass|blank-pass/);
149+
// Page text masks the same values, so it can't be compared against the tree.
150+
expect(result.visibleText).toContain("Order ••••••••-2");
151+
expect(tree).toMatch(/row "password: •+"/);
152+
expect(tree).toMatch(/textbox "Username" [^\n]*: maria$/m);
153+
const line = tree.split("\n").find((line) => line.includes('textbox "Password"'));
154+
expect(line).toMatch(/: •+$/);
155+
await ServerBrowserPage.type(page, { locator: locators(line)[0]!, text: "next", clear: true });
156+
expect(await page.locator("#pw").inputValue()).toBe("next");
157+
});
158+
127159
it("rejects refs from another tab", async () => {
128160
await page.setContent("<button>same label</button>");
129161
const locator = buttonLocator((await takeSnapshot()).accessibilityTree, "same label");

0 commit comments

Comments
 (0)