1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
| #!/usr/bin/env node
import { chromium } from '@playwright/test';
import { writeFileSync, readdirSync, readFileSync, statSync } from 'fs';
import { join } from 'path';
const argv = process.argv.slice(2);
const arg = (name, fallback = null) => {
const i = argv.indexOf(`--${name}`);
return i >= 0 && argv[i + 1] ? argv[i + 1] : fallback;
};
const BASE = (arg('base', process.env.SMOKE_HOST || 'https://gluecron.com')).replace(/\/$/, '');
const EXPECT_SHA = arg('expect-sha', process.env.EXPECT_SHA);
const PRIVATE_REPO = arg('private-repo', process.env.PRIVATE_REPO);
const PUBLIC_REPO = arg('public-repo', process.env.PUBLIC_REPO);
const OWNER_PAT = process.env.GLUECRON_PAT;
const NONMEMBER_PAT = process.env.NONMEMBER_PAT;
const JSON_OUT = arg('json');
function repoScopedGetRoutes(root = 'src/routes') {
const files = [];
const walk = (d) => {
for (const e of readdirSync(d)) {
const p = join(d, e);
if (statSync(p).isDirectory()) walk(p);
else if (e.endsWith('.ts') || e.endsWith('.tsx')) files.push(p);
}
};
try { walk(root); } catch { return []; }
const re = /\.(get)\(\s*(["'`])(\/:owner\/:repo[^"'`\n]*)\2/g;
const paths = new Set();
for (const f of files) {
const src = readFileSync(f, 'utf8');
let m;
re.lastIndex = 0;
while ((m = re.exec(src))) {
let p = m[3];
if (p.includes('.git')) continue;
p = p.replace(/\{[^}]*\}/g, '');
paths.add(p);
}
}
return [...paths].sort();
}
function materialize(routePath, owner, repo) {
return routePath
.replace('/:owner/:repo', `/${owner}/${repo}`)
.replace(/\/:[A-Za-z_]+\??/g, '/_probe')
.replace(/\/\*$/, '/_probe');
}
const PAGES = [
'/', '/explore', '/pricing', '/docs', '/docs/agents', '/docs/api',
'/login', '/register', '/marketplace', '/enterprise',
];
const AUTH_ONLY = ['/dashboard', '/settings', '/admin', '/settings/tokens'];
const PERF_BUDGET_MS = 3000;
const results = [];
const add = (gate, hard, ok, detail) => results.push({ gate, hard, ok, detail });
async function main() {
console.log(`[readiness] target: ${BASE}\n`);
try {
const r = await fetch(`${BASE}/api/version`);
const v = await r.json();
const sha = String(v.sha || '');
const bad = !sha || sha === 'unknown' || sha === 'dev';
if (bad) {
add('provenance', true, false,
`/api/version reports sha="${sha}" — the build SHA never reached the running process, so deploy detection and PWA cache-busting are both inert`);
} else if (EXPECT_SHA && !EXPECT_SHA.startsWith(v.shaFull) && !v.shaFull?.startsWith(sha)) {
add('provenance', true, false, `live sha ${v.shaFull} != expected ${EXPECT_SHA} — deploy did not land`);
} else {
add('provenance', true, true, `sha=${sha} builtAt=${v.builtAt}`);
}
} catch (e) {
add('provenance', true, false, `/api/version unreachable: ${e.message}`);
}
try {
const r = await fetch(`${BASE}/api/definitely-not-a-real-endpoint-${Date.now()}`);
const ct = r.headers.get('content-type') || '';
const body = (await r.text()).slice(0, 400);
const isHtml = ct.includes('text/html') || body.trimStart().startsWith('<');
add('api-json', true, !isHtml,
isHtml
? `unknown /api/* path returned ${r.status} as ${ct || 'HTML'} — API and MCP clients cannot parse this`
: `unknown /api/* path returned ${r.status} as ${ct}`);
} catch (e) {
add('api-json', true, false, `probe failed: ${e.message}`);
}
if (PRIVATE_REPO) {
const [o, n] = PRIVATE_REPO.split('/');
const surfaces = [`/api/repos/${o}/${n}`, `/${o}/${n}`, `/api/v2/repos/${o}/${n}`];
const leaks = [];
for (const path of surfaces) {
try {
const r = await fetch(`${BASE}${path}`);
if (r.status !== 200) continue;
const body = await r.text();
if (/"isPrivate"|"diskPath"|"ownerId"/.test(body)) {
leaks.push(`${path} -> 200 disclosing repo metadata`);
}
} catch { }
}
add('privacy', true, leaks.length === 0,
leaks.length ? leaks.join('; ') : `no anonymous disclosure across ${surfaces.length} surfaces`);
} else {
add('privacy', true, true, 'SKIPPED — pass --private-repo owner/name to enable (strongly recommended)');
}
if (PRIVATE_REPO && PUBLIC_REPO) {
const [po, pn] = PRIVATE_REPO.split('/');
const [uo, un] = PUBLIC_REPO.split('/');
const routes = repoScopedGetRoutes();
const leaks = [];
const overblocked = [];
const errors = [];
const probe = async (path, token) => {
const headers = token ? { authorization: `Bearer ${token}` } : {};
try {
const r = await fetch(`${BASE}${path}`, { headers, redirect: 'manual' });
return r.status;
} catch {
return 0;
}
};
const LIMIT = 6;
let cursor = 0;
const worker = async () => {
for (;;) {
const i = cursor++;
if (i >= routes.length) return;
await checkRoute(routes[i]);
}
};
async function checkRoute(route) {
const anon = await probe(materialize(route, po, pn), null);
if (anon === 200) leaks.push(`anon ${route} -> 200`);
if (NONMEMBER_PAT) {
const nm = await probe(materialize(route, po, pn), NONMEMBER_PAT);
if (nm === 200) leaks.push(`non-member ${route} -> 200`);
}
if (OWNER_PAT) {
const own = await probe(materialize(route, uo, un), OWNER_PAT);
if (own === 302 || own === 401 || own === 403) {
overblocked.push(`owner ${route} -> ${own}`);
}
if (own >= 500) errors.push(`${route} -> ${own}`);
}
}
const detail = [];
if (leaks.length) detail.push(`LEAK: ${leaks.slice(0, 8).join(', ')}`);
if (overblocked.length) detail.push(`OVER-BLOCKED: ${overblocked.slice(0, 8).join(', ')}`);
if (errors.length) detail.push(`5xx: ${errors.slice(0, 8).join(', ')}`);
const covered = `${routes.length} repo routes x ${NONMEMBER_PAT ? 3 : 2} identities`;
add('authz-matrix', true, leaks.length === 0 && overblocked.length === 0 && errors.length === 0,
detail.length ? detail.join(' | ') : `${covered}, no leaks or over-blocking`
+ (NONMEMBER_PAT ? '' : ' (set NONMEMBER_PAT for the non-member row)'));
} else {
add('authz-matrix', true, true,
'SKIPPED — needs --private-repo AND --public-repo (this is the gate that catches leaks; enable it)');
}
const rendered = [];
for (const p of AUTH_ONLY) {
try {
const r = await fetch(`${BASE}${p}`, { redirect: 'manual' });
if (r.status >= 200 && r.status < 300) {
const body = await r.text();
if (!/sign in|log ?in|password/i.test(body.slice(0, 4000))) rendered.push(`${p} -> ${r.status}`);
}
} catch { }
}
add('auth-gate', true, rendered.length === 0,
rendered.length ? `rendered to anonymous caller: ${rendered.join(', ')}` : `${AUTH_ONLY.length} paths correctly gated`);
const browser = await chromium.launch();
const jsErrors = [], overflows = [], brokenImgs = [], slow = [], noH1 = [];
for (const vp of [{ w: 1440, h: 900 }, { w: 390, h: 844 }]) {
const ctx = await browser.newContext({ viewport: { width: vp.w, height: vp.h } });
for (const path of PAGES) {
const page = await ctx.newPage();
const errs = [];
page.on('pageerror', (e) => errs.push(String(e).slice(0, 200)));
const t0 = Date.now();
try {
await page.goto(BASE + path, { waitUntil: 'domcontentloaded', timeout: 45000 });
try { await page.waitForLoadState('networkidle', { timeout: 8000 }); } catch {}
const ms = Date.now() - t0;
const probe = await page.evaluate(() => ({
scrollW: document.documentElement.scrollWidth,
innerW: window.innerWidth,
h1: document.querySelectorAll('h1').length,
broken: Array.from(document.images)
.filter((im) => im.complete && im.naturalWidth === 0)
.map((im) => im.src.slice(0, 120)),
}));
if (probe.scrollW > probe.innerW + 2) {
overflows.push(`${path} @${vp.w}: ${probe.scrollW}px (+${probe.scrollW - probe.innerW})`);
}
if (probe.broken.length) brokenImgs.push(`${path}: ${probe.broken.length}`);
if (vp.w === 1440) {
if (probe.h1 === 0) noH1.push(path);
if (ms > PERF_BUDGET_MS) slow.push(`${path} ${ms}ms`);
}
} catch (e) {
errs.push(`navigation failed: ${String(e).slice(0, 160)}`);
}
if (errs.length) jsErrors.push(`${path} @${vp.w}: ${errs[0]}`);
await page.close();
}
await ctx.close();
}
await browser.close();
add('render', true, jsErrors.length === 0,
jsErrors.length ? jsErrors.slice(0, 5).join(' | ') : `${PAGES.length} pages x2 viewports, no uncaught JS errors`);
add('overflow', true, overflows.length === 0,
overflows.length ? overflows.slice(0, 6).join(' | ') : 'no horizontal overflow at 1440 or 390');
add('images', false, brokenImgs.length === 0,
brokenImgs.length ? brokenImgs.join(' | ') : 'no broken images');
add('headings', false, noH1.length === 0,
noH1.length ? `${noH1.length} page(s) with no <h1>: ${noH1.slice(0, 6).join(', ')}` : 'every sampled page has an h1');
add('perf', false, slow.length === 0,
slow.length ? `over ${PERF_BUDGET_MS}ms: ${slow.join(', ')}` : `all sampled pages under ${PERF_BUDGET_MS}ms`);
const pad = (s, n) => String(s).padEnd(n);
console.log(pad('GATE', 13) + pad('KIND', 7) + pad('RESULT', 8) + 'DETAIL');
console.log('-'.repeat(100));
for (const r of results) {
console.log(
pad(r.gate, 13) + pad(r.hard ? 'HARD' : 'soft', 7) +
pad(r.ok ? 'PASS' : 'FAIL', 8) + r.detail
);
}
const hardFails = results.filter((r) => r.hard && !r.ok);
const softFails = results.filter((r) => !r.hard && !r.ok);
console.log('');
console.log(`[readiness] HARD ${results.filter(r => r.hard && r.ok).length}/${results.filter(r => r.hard).length} passed · soft warnings: ${softFails.length}`);
if (JSON_OUT) {
writeFileSync(JSON_OUT, JSON.stringify({ base: BASE, results }, null, 2));
console.log(`[readiness] wrote ${JSON_OUT}`);
}
if (hardFails.length) {
console.error(`\n[readiness] NOT READY — ${hardFails.length} hard gate(s) failed:`);
for (const f of hardFails) console.error(` - ${f.gate}: ${f.detail}`);
process.exit(1);
}
console.log('\n[readiness] all hard gates passed');
process.exit(0);
}
main().catch((e) => {
console.error('[readiness] crashed:', e);
process.exit(2);
});
|