@1agh/maude 0.58.1 → 0.58.3
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/apps/studio/.ai/cache/_stats.json +1 -1
- package/apps/studio/acp/bridge.ts +165 -15
- package/apps/studio/annotations-bindings.ts +83 -4
- package/apps/studio/api.ts +6 -1
- package/apps/studio/bin/_fetch-asset.mjs +169 -5
- package/apps/studio/bin/_import-asset.mjs +72 -0
- package/apps/studio/bin/_import-figma.mjs +1121 -0
- package/apps/studio/bin/_video-playwright.mjs +86 -3
- package/apps/studio/bin/import-figma.sh +38 -0
- package/apps/studio/bin/read-annotations.mjs +11 -1
- package/apps/studio/bun.lock +16 -22
- package/apps/studio/canvas-edit.ts +29 -5
- package/apps/studio/client/app.jsx +129 -23
- package/apps/studio/client/export-center.jsx +42 -4
- package/apps/studio/client/panels/ChatPanel.jsx +25 -2
- package/apps/studio/client/panels/CloudBar.jsx +92 -1
- package/apps/studio/client/panels/FigmaImportPanel.jsx +264 -0
- package/apps/studio/client/panels/GitPanel.jsx +26 -6
- package/apps/studio/client/panels/SettingsPanel.jsx +181 -0
- package/apps/studio/client/panels/SetupChecklist.jsx +26 -2
- package/apps/studio/client/panels/TimelinePanel.jsx +2 -2
- package/apps/studio/client/panels/timeline-parse.js +3 -3
- package/apps/studio/client/styles/3-shell-maude.css +7 -0
- package/apps/studio/client/styles/4-components.css +134 -0
- package/apps/studio/client/styles/6-acp-chat.css +12 -0
- package/apps/studio/clip-ops.ts +93 -17
- package/apps/studio/cloud/endpoints.ts +78 -10
- package/apps/studio/cloud/renew.ts +183 -0
- package/apps/studio/context.ts +2 -1
- package/apps/studio/dist/client.bundle.js +1491 -1491
- package/apps/studio/dist/runtime/@remotion_media.js +56 -136
- package/apps/studio/dist/runtime/@remotion_player.js +18 -18
- package/apps/studio/dist/runtime/@remotion_transitions.js +9 -9
- package/apps/studio/dist/runtime/@remotion_transitions_clock-wipe.js +1 -1
- package/apps/studio/dist/runtime/remotion.js +12 -12
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/exporters/_browser-bundles.ts +20 -6
- package/apps/studio/exporters/_runtime.ts +19 -0
- package/apps/studio/exporters/degraded.ts +92 -0
- package/apps/studio/exporters/index.ts +5 -0
- package/apps/studio/exporters/jobs.ts +19 -0
- package/apps/studio/exporters/unsupported-media.ts +170 -0
- package/apps/studio/exporters/video-encode-lib.ts +27 -1
- package/apps/studio/exporters/video-render-lib.ts +6 -0
- package/apps/studio/exporters/video.ts +62 -1
- package/apps/studio/figma/assets.test.ts +372 -0
- package/apps/studio/figma/assets.ts +398 -0
- package/apps/studio/figma/client.test.ts +395 -0
- package/apps/studio/figma/client.ts +513 -0
- package/apps/studio/figma/comments-to-strokes.test.ts +194 -0
- package/apps/studio/figma/comments-to-strokes.ts +173 -0
- package/apps/studio/figma/endpoints.ts +200 -0
- package/apps/studio/figma/sanitize.test.ts +256 -0
- package/apps/studio/figma/sanitize.ts +315 -0
- package/apps/studio/figma/style-map.ts +352 -0
- package/apps/studio/figma/to-artboard.test.ts +808 -0
- package/apps/studio/figma/to-artboard.ts +701 -0
- package/apps/studio/figma/to-render.test.ts +180 -0
- package/apps/studio/figma/to-render.ts +306 -0
- package/apps/studio/figma/to-strokes-roundtrip.test.ts +152 -0
- package/apps/studio/figma/to-strokes.test.ts +705 -0
- package/apps/studio/figma/to-strokes.ts +749 -0
- package/apps/studio/figma/to-tokens.test.ts +321 -0
- package/apps/studio/figma/to-tokens.ts +305 -0
- package/apps/studio/figma/types.ts +539 -0
- package/apps/studio/figma/url.test.ts +167 -0
- package/apps/studio/figma/url.ts +160 -0
- package/apps/studio/http.ts +129 -0
- package/apps/studio/sync/asset-push.ts +124 -0
- package/apps/studio/sync/canvas-path.ts +329 -0
- package/apps/studio/sync/codec.ts +42 -0
- package/apps/studio/sync/connection-state.ts +11 -0
- package/apps/studio/sync/hub-link.ts +63 -7
- package/apps/studio/sync/hubs-config.ts +31 -3
- package/apps/studio/sync/index.ts +755 -32
- package/apps/studio/sync/migrate-flat-fallback.ts +121 -0
- package/apps/studio/sync/presentation.ts +45 -1
- package/apps/studio/sync/projection.ts +11 -1
- package/apps/studio/sync/remote-docs.ts +122 -15
- package/apps/studio/sync/supervisor.ts +5 -1
- package/apps/studio/sync/workspace-signin.ts +7 -3
- package/apps/studio/test/acp-bridge-lifetime.test.ts +106 -0
- package/apps/studio/test/annotations-bindings.test.ts +150 -12
- package/apps/studio/test/canvas-create-api.test.ts +4 -1
- package/apps/studio/test/canvas-origin-gate.test.ts +13 -0
- package/apps/studio/test/capture-determinism-shape.test.ts +135 -0
- package/apps/studio/test/clip-addressing.test.ts +6 -1
- package/apps/studio/test/clip-ops.test.ts +5 -1
- package/apps/studio/test/cloud-endpoints.test.ts +96 -0
- package/apps/studio/test/cloud-renew.test.ts +205 -0
- package/apps/studio/test/cloud-shell-surfaces.test.ts +11 -2
- package/apps/studio/test/comment-relay-origin-gate.test.ts +117 -0
- package/apps/studio/test/comments-fs-rebroadcast.test.ts +155 -0
- package/apps/studio/test/exporters/degraded-propagation.test.ts +123 -0
- package/apps/studio/test/exporters/unsupported-media.test.ts +123 -0
- package/apps/studio/test/fetch-asset-gate.test.ts +189 -0
- package/apps/studio/test/figma-provenance.test.ts +108 -0
- package/apps/studio/test/figma-routes.test.ts +294 -0
- package/apps/studio/test/fixtures/mock-acp-agent-wedged.mjs +37 -0
- package/apps/studio/test/git-cloud-posture.test.ts +50 -0
- package/apps/studio/test/hub-link.test.ts +11 -0
- package/apps/studio/test/import-figma.test.ts +479 -0
- package/apps/studio/test/sync-asset-push.test.ts +124 -0
- package/apps/studio/test/sync-canvas-path.test.ts +200 -0
- package/apps/studio/test/sync-connection-state.test.ts +13 -0
- package/apps/studio/test/sync-hubs-config.test.ts +5 -0
- package/apps/studio/test/sync-migrate-flat-fallback.test.ts +98 -0
- package/apps/studio/test/sync-path-pull.test.ts +465 -0
- package/apps/studio/test/sync-presentation.test.ts +77 -0
- package/apps/studio/test/sync-remote-docs.test.ts +55 -3
- package/apps/studio/test/sync-runtime.test.ts +434 -1
- package/apps/studio/test/video-comp.test.ts +23 -1
- package/apps/studio/test/workspace-containment.test.ts +1 -0
- package/apps/studio/video-comp.tsx +70 -6
- package/apps/studio/whats-new.json +36 -0
- package/apps/studio/workspace-mode.ts +4 -0
- package/cli/commands/design.mjs +8 -0
- package/package.json +8 -8
- package/plugins/flow/.claude-plugin/config.schema.json +3 -3
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// `/_api/figma/*` — the MAIN-origin half of DDR-216 D3.
|
|
2
|
+
//
|
|
3
|
+
// canvas-origin-gate.test.ts already asserts these routes are unreachable from
|
|
4
|
+
// the segregated canvas origin. That proves the wrong property on its own: the
|
|
5
|
+
// MAIN origin is reachable from any website the user visits while the dev
|
|
6
|
+
// server is up. Round 1 of the DDR-216 security review found the first draft
|
|
7
|
+
// named no CSRF / DNS-rebind guard at all, with a working PoC — a CORS-simple
|
|
8
|
+
// POST that plants an attacker's PAT (`connect`) or spends the user's on an
|
|
9
|
+
// attacker-chosen key (`probe`), opaque response, real side effect.
|
|
10
|
+
//
|
|
11
|
+
// So this file asserts the complementary half:
|
|
12
|
+
// • cross-site → 403 (Sec-Fetch-Site, the `sameOriginWrite` guard)
|
|
13
|
+
// • foreign Host header → 403 (the DNS-rebinding `isTrustedRequestHost` guard)
|
|
14
|
+
// • the stored key is NEVER echoed on ANY response path
|
|
15
|
+
// • `probe` is gated as a WRITE even though it stores nothing — it spends the
|
|
16
|
+
// credential and reaches the network.
|
|
17
|
+
|
|
18
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { tmpdir } from 'node:os';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
import type { Subprocess } from 'bun';
|
|
23
|
+
|
|
24
|
+
import { bootServer, killProc, makeSandbox, nextPort } from './_helpers.ts';
|
|
25
|
+
|
|
26
|
+
const TOKEN = 'figd_ROUTECANARY_0123456789abcdef';
|
|
27
|
+
|
|
28
|
+
let proc: Subprocess;
|
|
29
|
+
let port: number;
|
|
30
|
+
let base: string;
|
|
31
|
+
let keysPath: string;
|
|
32
|
+
let keysDir: string;
|
|
33
|
+
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
const { root } = makeSandbox();
|
|
36
|
+
keysDir = mkdtempSync(join(tmpdir(), 'maude-figma-routes-keys-'));
|
|
37
|
+
keysPath = join(keysDir, 'keys.json');
|
|
38
|
+
writeFileSync(keysPath, JSON.stringify({ keys: {} }), { mode: 0o600 });
|
|
39
|
+
port = nextPort();
|
|
40
|
+
base = `http://localhost:${port}`;
|
|
41
|
+
proc = await bootServer(root, port, { MAUDE_GEN_KEYS_PATH: keysPath });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterAll(async () => {
|
|
45
|
+
await killProc(proc);
|
|
46
|
+
rmSync(keysDir, { recursive: true, force: true });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function storedToken(): string | undefined {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(readFileSync(keysPath, 'utf8')).keys?.figma;
|
|
52
|
+
} catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The WRITE guard in this codebase is `sameOriginWrite`, which keys on `Origin`
|
|
58
|
+
// — the header a browser stamps unspoofably on every cross-origin POST/DELETE.
|
|
59
|
+
// (`Sec-Fetch-Site` is what `sameOriginRead` uses, for the GET case below where
|
|
60
|
+
// browsers do NOT reliably send Origin.) These tests therefore send a real
|
|
61
|
+
// cross-origin `Origin`, which is what an attacker page actually produces.
|
|
62
|
+
describe('cross-origin writes are refused (the CSRF guard)', () => {
|
|
63
|
+
const EVIL = 'https://evil.example';
|
|
64
|
+
const PLANTED = 'figd_ATTACKER_PLANTED_0123456789';
|
|
65
|
+
|
|
66
|
+
test('POST /_api/figma/connect cross-origin is 403 and stores nothing', async () => {
|
|
67
|
+
const res = await fetch(`${base}/_api/figma/connect`, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: { 'Content-Type': 'application/json', Origin: EVIL },
|
|
70
|
+
body: JSON.stringify({ token: PLANTED }),
|
|
71
|
+
});
|
|
72
|
+
expect(res.status).toBe(403);
|
|
73
|
+
expect(storedToken()).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('POST /_api/figma/probe cross-origin is 403 — probe spends the credential', async () => {
|
|
77
|
+
const res = await fetch(`${base}/_api/figma/probe`, {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
headers: { Origin: EVIL },
|
|
80
|
+
});
|
|
81
|
+
expect(res.status).toBe(403);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('DELETE /_api/figma/connect cross-origin is 403', async () => {
|
|
85
|
+
const res = await fetch(`${base}/_api/figma/connect`, {
|
|
86
|
+
method: 'DELETE',
|
|
87
|
+
headers: { Origin: EVIL },
|
|
88
|
+
});
|
|
89
|
+
expect(res.status).toBe(403);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('a CORS-simple POST (no preflight, text/plain) is still refused', async () => {
|
|
93
|
+
// The PoC shape from the DDR-216 review: a simple content type means no
|
|
94
|
+
// preflight and the page cannot read the response — but the side effect
|
|
95
|
+
// would land if the server allowed it. Origin is still stamped.
|
|
96
|
+
const res = await fetch(`${base}/_api/figma/connect`, {
|
|
97
|
+
method: 'POST',
|
|
98
|
+
headers: { 'Content-Type': 'text/plain', Origin: EVIL },
|
|
99
|
+
body: JSON.stringify({ token: PLANTED }),
|
|
100
|
+
});
|
|
101
|
+
expect(res.status).toBe(403);
|
|
102
|
+
expect(storedToken()).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('cross-site reads are refused (Sec-Fetch-Site, the GET case)', () => {
|
|
107
|
+
test('GET /_api/figma/status with Sec-Fetch-Site: cross-site is 403', async () => {
|
|
108
|
+
// A no-cors GET from an attacker page passes the loopback guard and may omit
|
|
109
|
+
// Origin entirely, so `sameOriginWrite` cannot see it. Without the read
|
|
110
|
+
// guard this leaks whether the user has Figma connected.
|
|
111
|
+
const res = await fetch(`${base}/_api/figma/status`, {
|
|
112
|
+
headers: { 'Sec-Fetch-Site': 'cross-site' },
|
|
113
|
+
});
|
|
114
|
+
expect(res.status).toBe(403);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('a foreign Host header is refused (the DNS-rebinding guard)', () => {
|
|
119
|
+
for (const [label, host] of [
|
|
120
|
+
['an attacker-controlled name', 'evil.example'],
|
|
121
|
+
['a rebinding service name', 'figma.127.0.0.1.nip.io'],
|
|
122
|
+
]) {
|
|
123
|
+
test(`GET /_api/figma/status with Host: ${label} is 403`, async () => {
|
|
124
|
+
const res = await fetch(`${base}/_api/figma/status`, { headers: { Host: host } });
|
|
125
|
+
expect(res.status).toBe(403);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('method gating', () => {
|
|
131
|
+
test('GET /_api/figma/connect is 405', async () => {
|
|
132
|
+
expect((await fetch(`${base}/_api/figma/connect`)).status).toBe(405);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('GET /_api/figma/probe is 405 — probe is a write', async () => {
|
|
136
|
+
expect((await fetch(`${base}/_api/figma/probe`)).status).toBe(405);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('POST /_api/figma/status is 405', async () => {
|
|
140
|
+
expect((await fetch(`${base}/_api/figma/status`, { method: 'POST' })).status).toBe(405);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe('same-origin happy path — and the key never comes back out', () => {
|
|
145
|
+
test('status reports presence only, plus the granular scope to ask for', async () => {
|
|
146
|
+
const res = await fetch(`${base}/_api/figma/status`, {
|
|
147
|
+
headers: { 'Sec-Fetch-Site': 'same-origin' },
|
|
148
|
+
});
|
|
149
|
+
expect(res.status).toBe(200);
|
|
150
|
+
const body = (await res.json()) as Record<string, unknown>;
|
|
151
|
+
expect(body.configured).toBe(false);
|
|
152
|
+
// The blanket `files:read` scope is deprecated — the UI must never name it.
|
|
153
|
+
expect(body.requiredScope).toBe('file_content:read');
|
|
154
|
+
expect(JSON.stringify(body)).not.toContain('figd_');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('connect stores the key and returns presence only — never the value', async () => {
|
|
158
|
+
const res = await fetch(`${base}/_api/figma/connect`, {
|
|
159
|
+
method: 'POST',
|
|
160
|
+
headers: { 'Content-Type': 'application/json', 'Sec-Fetch-Site': 'same-origin' },
|
|
161
|
+
body: JSON.stringify({ token: TOKEN }),
|
|
162
|
+
});
|
|
163
|
+
expect(res.status).toBe(200);
|
|
164
|
+
const raw = await res.text();
|
|
165
|
+
expect(JSON.parse(raw)).toEqual({ configured: true });
|
|
166
|
+
expect(raw).not.toContain(TOKEN);
|
|
167
|
+
expect(raw).not.toContain('ROUTECANARY');
|
|
168
|
+
// It really did store it — the assertion above is about the RESPONSE, not
|
|
169
|
+
// about the write silently failing.
|
|
170
|
+
expect(storedToken()).toBe(TOKEN);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('status still never echoes the value once one is configured', async () => {
|
|
174
|
+
const res = await fetch(`${base}/_api/figma/status`, {
|
|
175
|
+
headers: { 'Sec-Fetch-Site': 'same-origin' },
|
|
176
|
+
});
|
|
177
|
+
const raw = await res.text();
|
|
178
|
+
expect(JSON.parse(raw).configured).toBe(true);
|
|
179
|
+
expect(raw).not.toContain('ROUTECANARY');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('a malformed token is refused with a message that does not echo it', async () => {
|
|
183
|
+
const junk = 'not a token REFLECTION_CANARY';
|
|
184
|
+
const res = await fetch(`${base}/_api/figma/connect`, {
|
|
185
|
+
method: 'POST',
|
|
186
|
+
headers: { 'Content-Type': 'application/json', 'Sec-Fetch-Site': 'same-origin' },
|
|
187
|
+
body: JSON.stringify({ token: junk }),
|
|
188
|
+
});
|
|
189
|
+
expect(res.status).toBe(400);
|
|
190
|
+
const raw = await res.text();
|
|
191
|
+
expect(raw).not.toContain('REFLECTION_CANARY');
|
|
192
|
+
// The previously-stored good token is untouched by a failed write.
|
|
193
|
+
expect(storedToken()).toBe(TOKEN);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('probe surfaces a typed failure without leaking the token', async () => {
|
|
197
|
+
// No network stub here — the real api.figma.com will reject this canary
|
|
198
|
+
// token (or the call fails to connect in CI). Either way the response must
|
|
199
|
+
// be a typed reason with a code-owned message and no credential in it.
|
|
200
|
+
const res = await fetch(`${base}/_api/figma/probe`, {
|
|
201
|
+
method: 'POST',
|
|
202
|
+
headers: { 'Sec-Fetch-Site': 'same-origin' },
|
|
203
|
+
});
|
|
204
|
+
const raw = await res.text();
|
|
205
|
+
expect(raw).not.toContain('ROUTECANARY');
|
|
206
|
+
expect(raw).not.toContain('figd_');
|
|
207
|
+
const body = JSON.parse(raw) as { ok: boolean; reason?: string };
|
|
208
|
+
if (!body.ok) {
|
|
209
|
+
expect(['unauthorized', 'forbidden', 'network', 'bad_response', 'rate_limited']).toContain(
|
|
210
|
+
body.reason
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test('disconnect clears the key', async () => {
|
|
216
|
+
const res = await fetch(`${base}/_api/figma/connect`, {
|
|
217
|
+
method: 'DELETE',
|
|
218
|
+
headers: { 'Sec-Fetch-Site': 'same-origin' },
|
|
219
|
+
});
|
|
220
|
+
expect(res.status).toBe(200);
|
|
221
|
+
expect(await res.json()).toEqual({ configured: false });
|
|
222
|
+
expect(storedToken()).toBeUndefined();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('/_api/figma/import — same gate, and a validated body', () => {
|
|
227
|
+
test('cross-origin is 403 — it spends the PAT and writes to disk', async () => {
|
|
228
|
+
const res = await fetch(`${base}/_api/figma/import`, {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
headers: { 'Content-Type': 'application/json', Origin: 'https://evil.example' },
|
|
231
|
+
body: JSON.stringify({ mode: 'board', url: 'https://www.figma.com/board/AAAAAAAAAA/x' }),
|
|
232
|
+
});
|
|
233
|
+
expect(res.status).toBe(403);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test('a foreign Host is 403', async () => {
|
|
237
|
+
const res = await fetch(`${base}/_api/figma/import`, {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
headers: { Host: 'evil.example' },
|
|
240
|
+
body: '{}',
|
|
241
|
+
});
|
|
242
|
+
expect(res.status).toBe(403);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('GET is 405', async () => {
|
|
246
|
+
expect((await fetch(`${base}/_api/figma/import`)).status).toBe(405);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test.each([
|
|
250
|
+
['no body', {}],
|
|
251
|
+
['unknown mode', { mode: 'everything', url: 'https://www.figma.com/board/AAAAAAAAAA/x' }],
|
|
252
|
+
['missing url', { mode: 'board' }],
|
|
253
|
+
['empty url', { mode: 'board', url: '' }],
|
|
254
|
+
])('a malformed request is 400 (%s)', async (_label, body) => {
|
|
255
|
+
const res = await fetch(`${base}/_api/figma/import`, {
|
|
256
|
+
method: 'POST',
|
|
257
|
+
headers: { 'Content-Type': 'application/json', 'Sec-Fetch-Site': 'same-origin' },
|
|
258
|
+
body: JSON.stringify(body),
|
|
259
|
+
});
|
|
260
|
+
expect(res.status).toBe(400);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('a caller cannot choose an output path', async () => {
|
|
264
|
+
// The body shape is fixed: {mode, url, dryRun}. A slug/path/into field is
|
|
265
|
+
// simply not read — the same "the producer never picks its own target"
|
|
266
|
+
// discipline DDR-174 applies to its authoring agent.
|
|
267
|
+
const res = await fetch(`${base}/_api/figma/import`, {
|
|
268
|
+
method: 'POST',
|
|
269
|
+
headers: { 'Content-Type': 'application/json', 'Sec-Fetch-Site': 'same-origin' },
|
|
270
|
+
body: JSON.stringify({
|
|
271
|
+
mode: 'board',
|
|
272
|
+
url: 'https://www.figma.com/board/AAAAAAAAAA/x',
|
|
273
|
+
slug: '../../etc/passwd',
|
|
274
|
+
into: '/etc/passwd',
|
|
275
|
+
}),
|
|
276
|
+
});
|
|
277
|
+
// It gets past validation (the url is well-formed) and fails on the
|
|
278
|
+
// credential instead — the point is that the path fields were ignored.
|
|
279
|
+
const raw = await res.text();
|
|
280
|
+
expect(raw).not.toContain('etc/passwd');
|
|
281
|
+
expect([400, 502]).toContain(res.status);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test('a failure never echoes an upstream string', async () => {
|
|
285
|
+
const res = await fetch(`${base}/_api/figma/import`, {
|
|
286
|
+
method: 'POST',
|
|
287
|
+
headers: { 'Content-Type': 'application/json', 'Sec-Fetch-Site': 'same-origin' },
|
|
288
|
+
body: JSON.stringify({ mode: 'board', url: 'https://www.figma.com/board/AAAAAAAAAA/x' }),
|
|
289
|
+
});
|
|
290
|
+
const raw = await res.text();
|
|
291
|
+
expect(raw).not.toContain('figd_');
|
|
292
|
+
expect(raw).not.toContain('ROUTECANARY');
|
|
293
|
+
});
|
|
294
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// A mock ACP agent that WEDGES on the FIRST turn only (issue-82): its
|
|
3
|
+
// `session/prompt` handler never resolves for call #1 — simulating a
|
|
4
|
+
// `claude` subprocess that has hung — and it never implements
|
|
5
|
+
// `session/cancel` at all, so a bridge that only sends the cooperative ACP
|
|
6
|
+
// `session/cancel` request and trusts it will hang forever, exactly like the
|
|
7
|
+
// reported "I clicked STOP and nothing happened" bug.
|
|
8
|
+
//
|
|
9
|
+
// Every call AFTER the first resolves normally and quickly — this lets a
|
|
10
|
+
// test start a second, overlapping `prompt()` on the same bridge/chat (the
|
|
11
|
+
// ethical-hacker's "no reentrancy guard" finding) and confirm that turn's
|
|
12
|
+
// ordinary completion doesn't blind `cancel()` to the still-wedged first one.
|
|
13
|
+
|
|
14
|
+
import { Readable, Writable } from 'node:stream';
|
|
15
|
+
|
|
16
|
+
import * as acp from '@agentclientprotocol/sdk';
|
|
17
|
+
|
|
18
|
+
const stream = acp.ndJsonStream(Writable.toWeb(process.stdout), Readable.toWeb(process.stdin));
|
|
19
|
+
|
|
20
|
+
let promptCalls = 0;
|
|
21
|
+
|
|
22
|
+
acp
|
|
23
|
+
.agent({ name: 'mock-acp-agent-wedged' })
|
|
24
|
+
.onRequest('initialize', () => ({
|
|
25
|
+
protocolVersion: acp.PROTOCOL_VERSION,
|
|
26
|
+
agentCapabilities: { loadSession: false },
|
|
27
|
+
}))
|
|
28
|
+
.onRequest('session/new', () => ({ sessionId: 'mock-wedged-session' }))
|
|
29
|
+
.onRequest('session/prompt', () => {
|
|
30
|
+
promptCalls += 1;
|
|
31
|
+
if (promptCalls === 1) return new Promise(() => {}); // never resolves, never rejects
|
|
32
|
+
return Promise.resolve({ stopReason: 'end_turn' });
|
|
33
|
+
})
|
|
34
|
+
// Deliberately NO `session/cancel` handler — an agent that never
|
|
35
|
+
// implemented turn-cancellation at all, the other real-world shape of
|
|
36
|
+
// "Stop does nothing".
|
|
37
|
+
.connect(stream);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// DDR-218 (fix 8, sync RCA 2026-08-10) — the cloud-managed GitPanel posture.
|
|
2
|
+
//
|
|
3
|
+
// Source-level assertions, the cloud-shell-surfaces pattern: what these pin is
|
|
4
|
+
// exactly what would regress — someone gating the withdrawal on `historyOnly`
|
|
5
|
+
// alone (dropping the desktop half), breaking the live connect/disconnect
|
|
6
|
+
// reaction, or wiring `cloudManaged` from something other than the
|
|
7
|
+
// CORROBORATED link (`credentialed` — config.json alone is attacker-authorable,
|
|
8
|
+
// B2).
|
|
9
|
+
|
|
10
|
+
import { describe, expect, test } from 'bun:test';
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
|
|
14
|
+
const STUDIO = join(import.meta.dir, '..');
|
|
15
|
+
const APP = readFileSync(join(STUDIO, 'client', 'app.jsx'), 'utf8');
|
|
16
|
+
const GIT_PANEL = readFileSync(join(STUDIO, 'client', 'panels', 'GitPanel.jsx'), 'utf8');
|
|
17
|
+
const CLOUD_BAR = readFileSync(join(STUDIO, 'client', 'panels', 'CloudBar.jsx'), 'utf8');
|
|
18
|
+
|
|
19
|
+
describe('a cloud-linked repo shows ONE save mechanism (DDR-218)', () => {
|
|
20
|
+
test('cloudManaged withdraws exactly like the cell-side historyOnly', () => {
|
|
21
|
+
expect(GIT_PANEL).toContain('const withdrawn = historyOnly || cloudManaged;');
|
|
22
|
+
// Every render gate the working-tree half hides behind must read the
|
|
23
|
+
// merged flag — a `!historyOnly` guard reintroduces the desktop leak.
|
|
24
|
+
expect(GIT_PANEL).toMatch(/\{!withdrawn && \(\s*<div className="gp-tabs"/);
|
|
25
|
+
expect(GIT_PANEL).toContain("{tab === 'changes' && !withdrawn ? (");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('the posture reacts LIVE to connect/disconnect, not only at mount', () => {
|
|
29
|
+
// The initial useState alone would leave a freshly-linked panel on Changes.
|
|
30
|
+
expect(GIT_PANEL).toMatch(/useEffect\(\(\) => \{\s*if \(withdrawn\) setTab\('history'\);/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('the note names the active mechanism, and only in the desktop posture', () => {
|
|
34
|
+
expect(GIT_PANEL).toContain('data-testid="git-cloud-managed"');
|
|
35
|
+
expect(GIT_PANEL).toMatch(/\{cloudManaged && \(\s*<div className="gp-cloud-note"/);
|
|
36
|
+
expect(GIT_PANEL).toContain('Cloud is saving');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('the app gate is the CORROBORATED link, and the cell posture is untouched', () => {
|
|
40
|
+
expect(APP).toContain('cloudManaged={!cfg.cloud && !!cloudLinkedHub?.credentialed}');
|
|
41
|
+
expect(APP).toContain('historyOnly={!!cfg.cloud}');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('CloudBar lifts every link change the posture depends on', () => {
|
|
45
|
+
// status resolve + attach + detach — the three places the link changes.
|
|
46
|
+
const lifts = CLOUD_BAR.match(/onLinkedHub\?\.\(/g) ?? [];
|
|
47
|
+
expect(lifts.length).toBeGreaterThanOrEqual(3);
|
|
48
|
+
expect(APP).toContain('onLinkedHub={setCloudLinkedHub}');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -67,3 +67,14 @@ test('a second credential for the same hub replaces the token (per-machine key)'
|
|
|
67
67
|
// Trust is not duplicated.
|
|
68
68
|
expect(cfg.trusted.filter((u: string) => u === 'https://hub.example.dev')).toHaveLength(1);
|
|
69
69
|
});
|
|
70
|
+
|
|
71
|
+
test('role + expiresAt round-trip through the store (the renewal deadline survives)', () => {
|
|
72
|
+
saveHubCredential('https://hub.example.dev', 'mau_secret', 'member', 1786400000000);
|
|
73
|
+
const cfg = JSON.parse(readFileSync(process.env.HUBS_CONFIG_PATH as string, 'utf8'));
|
|
74
|
+
expect(cfg.hubs['https://hub.example.dev'].role).toBe('member');
|
|
75
|
+
expect(cfg.hubs['https://hub.example.dev'].expiresAt).toBe(1786400000000);
|
|
76
|
+
// Absent stays absent — a self-hosted hub's credential carries no deadline.
|
|
77
|
+
saveHubCredential('https://hub.example.dev', 'mau_secret2');
|
|
78
|
+
const cfg2 = JSON.parse(readFileSync(process.env.HUBS_CONFIG_PATH as string, 'utf8'));
|
|
79
|
+
expect(cfg2.hubs['https://hub.example.dev'].expiresAt).toBeUndefined();
|
|
80
|
+
});
|