From 16fafaee51f75e943261a0ec63560b6174a17531 Mon Sep 17 00:00:00 2001 From: infraclaw Date: Tue, 17 Nov 2026 21:29:53 +0000 Subject: [PATCH 1/3] Preserve Websites, AWS cost visibility and Mainnet monitoring in the console --- server/aws-public.js | 8 ++--- server/web.js | 7 +++- server/web.test.js | 37 +++++++++++++++++-- server/websites.js | 12 +++++++ server/websites.test.js | 33 +++++++++++++++++ shared/evaluate.js | 2 +- shared/mainnet.js | 66 ++++++++++++++++++++++++++++++---- shared/mainnet.test.js | 63 +++++++++++++++++++++++++++++++- src/App.jsx | 3 ++ src/pages/Aws.jsx | 14 ++++---- src/pages/Websites.jsx | 79 +++++++++++++++++++++++++++++++++++++++++ src/website-metrics.js | 29 +++++++++++++++ 12 files changed, 329 insertions(+), 24 deletions(-) create mode 100644 server/websites.js create mode 100644 server/websites.test.js create mode 100644 src/pages/Websites.jsx create mode 100644 src/website-metrics.js diff --git a/server/aws-public.js b/server/aws-public.js index 804e0e8..17b066a 100644 --- a/server/aws-public.js +++ b/server/aws-public.js @@ -1,4 +1,4 @@ -// The AWS inventory before sign-in: spend and breakdowns only. No resource +// The AWS inventory before sign-in: resource totals and breakdowns only. No resource // names, ids, addresses, DNS names or tags beyond the Dash network, and no // list of idle resources (that is for members). const add = (map, key, fields) => { @@ -8,7 +8,7 @@ const add = (map, key, fields) => { }; const rows = (map) => [...map.values()].map((e) => ({ ...e, memoryGiB: Math.round(e.memoryGiB) })).sort((a, b) => b.count - a.count || a.label.localeCompare(b.label)); -export function publicInventory(inv) { +export function publicInventory(inv, { includeCosts = false } = {}) { const running = inv.instances.filter((i) => i.state === 'running'); const byNetwork = new Map(), byRegion = new Map(), byFamily = new Map(), byArch = new Map(); for (const i of running) { @@ -21,7 +21,7 @@ export function publicInventory(inv) { for (const v of inv.volumes) ebsByType.set(v.type || 'unknown', (ebsByType.get(v.type || 'unknown') || 0) + (v.sizeGiB || 0)); const lbByType = {}; for (const l of inv.loadBalancers) lbByType[l.type] = (lbByType[l.type] || 0) + 1; - const c = inv.costs; + const c = includeCosts ? inv.costs : null; return { public: true, at: inv.at, regions: inv.regions.length, regionsInUse: new Set([...inv.instances, ...inv.volumes, ...inv.addresses, ...inv.loadBalancers, ...inv.natGateways].map((x) => x.region)).size, @@ -34,6 +34,6 @@ export function publicInventory(inv) { ecrImages: inv.ecr.reduce((a, r) => a + (r.images || 0), 0), s3Buckets: inv.s3.length }, network: { loadBalancers: inv.loadBalancers.length, loadBalancersByType: lbByType, natGateways: inv.natGateways.length, elasticIps: inv.addresses.length, cloudfront: inv.cloudfront.length }, serverless: { lambda: inv.lambda.length, dynamodb: inv.dynamodb.length }, - costs: c ? { at: c.at, month: c.month, currency: c.currency, monthToDate: c.monthToDate, monthEndEstimate: c.monthEndEstimate, lastMonth: c.lastMonth, byService: c.byService, daily: c.daily } : null, + ...(includeCosts ? { costs: c ? { at: c.at, month: c.month, currency: c.currency, monthToDate: c.monthToDate, monthEndEstimate: c.monthEndEstimate, lastMonth: c.lastMonth, byService: c.byService, daily: c.daily } : null } : {}), }; } diff --git a/server/web.js b/server/web.js index ff92a7e..598625a 100644 --- a/server/web.js +++ b/server/web.js @@ -7,6 +7,7 @@ import { randomUUID } from 'node:crypto'; import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, watch, openSync, readSync, closeSync } from 'node:fs'; import { join } from 'node:path'; import { fileURLToPath } from 'node:url'; +import { websiteReport } from './websites.js'; import { createAuth } from './auth.js'; import { createCi } from './ci.js'; import { createOrgQueue } from './ci-queue.js'; @@ -138,6 +139,7 @@ export function createWeb({ dataDir, origin, auth: authDeps, fetcher = fetch, cl res.status(stale ? 503 : 200).json({ ...body, stale }); }); + app.get('/api/websites', (req, res) => res.json(websiteReport(dataDir, clock()))); app.get('/api/health', (req, res) => res.json({ service: 'dash-status', status: 'ok' })); app.get('/api/remediation', (req, res) => { reloadSettings(); @@ -423,7 +425,10 @@ export function createWeb({ dataDir, origin, auth: authDeps, fetcher = fetch, cl app.get('/api/aws', (req, res) => { const inv = readJSON(join(awsDir, 'inventory.json')); if (!inv) return res.status(404).json({ error: 'No AWS inventory yet; the agent collects it every 10 minutes' }); - res.json(memberOf(settings, user(req)) ? inv : cached(`aws|${inv.at}`, () => publicInventory(inv))); + const viewer = user(req); + // Cost visibility follows the authenticated session, never query parameters. + // Keep signed-in summaries separate from the anonymous projection cache. + res.vary('Cookie').json(memberOf(settings, viewer) ? inv : cached(`aws|${viewer ? 'signed-in' : 'public'}|${inv.at}`, () => publicInventory(inv, { includeCosts: !!viewer }))); }); // GitHub account lookup so admins can grant access by login. diff --git a/server/web.test.js b/server/web.test.js index f8b998c..19f9744 100644 --- a/server/web.test.js +++ b/server/web.test.js @@ -239,20 +239,51 @@ test('CI: admins issue reporter tokens; reporters post with them; infrastructure costs: { at: 'now', month: '2026-09', monthToDate: 3270.85, monthEndEstimate: 3503.4, lastMonth: 3109.17, byService: [{ service: 'EC2 - Other', amount: 1178.9 }], daily: [] } })); assert.equal((await (await w.req('/api/aws')).json()).at, 'now'); assert.equal((await (await w.req('/api/aws')).json()).instances[0].publicIp, '192.0.2.9', 'members see the inventory'); + assert.equal((await (await w.req('/api/aws')).json()).costs.monthToDate, 3270.85, 'members retain costs'); assert.equal((await w.req(`/api/ci/reporters/${id}`, { method: 'DELETE', headers: { 'x-csrf-token': csrf } })).status, 200); - // Signed out: spend and breakdowns, nothing that names or locates a resource. + // Signed out: resource aggregates, no spend or resource identity. await w.req('/api/auth/logout', { method: 'POST', headers: { 'x-csrf-token': csrf } }); const pub = await (await w.req('/api/aws')).json(); assert.equal(pub.public, true); assert.deepEqual(pub.byNetwork, [{ label: 'testnet', count: 1, vcpus: 2, memoryGiB: 2 }]); - assert.equal(pub.costs.monthToDate, 3270.85); + assert.equal(pub.costs, undefined); const text = JSON.stringify(pub); - for (const leak of ['192.0.2.9', 'i-0123456789abcdef0', 'dn-testnet-masternode-1', 'testnet-alb', 'elb.amazonaws', 'killdate', 'rs-dapi', 'quorums.testnet', 'dash-terraform-state', 'vol-1']) + for (const leak of ['3270.85', '3503.4', '3109.17', '1178.9', '192.0.2.9', 'i-0123456789abcdef0', 'dn-testnet-masternode-1', 'testnet-alb', 'elb.amazonaws', 'killdate', 'rs-dapi', 'quorums.testnet', 'dash-terraform-state', 'vol-1']) assert.ok(!text.includes(leak), `leaked ${leak}`); assert.equal((await post(`Bearer ${token}`)).status, 401); } finally { w.close(); } }); +test('AWS costs require a valid session, including after cache warmup and logout', async () => { + const w = await start(42); // Signed-in user without inventory membership. + try { + const costs = { monthToDate: 1234.56, monthEndEstimate: 2345.67, lastMonth: 3456.78, + byService: [{ service: 'Fixture service', amount: 456.78 }], daily: [{ day: '2026-10-01', amount: 567.89 }] }; + writeFileSync(join(w.dataDir, 'aws', 'inventory.json'), JSON.stringify({ at: 'fixture', regions: [], + instances: [], volumes: [], addresses: [], natGateways: [], loadBalancers: [], lambda: [], + dynamodb: [], ecr: [], snapshots: [], cloudfront: [], s3: [], costs })); + const anonymous = async (path = '/api/aws', options) => { + const response = await w.req(path, options); + assert.equal(response.status, 200); + assert.equal(response.headers.get('cache-control'), 'no-store'); + assert.match(response.headers.get('vary'), /Cookie/i); + const body = await response.json(); + assert.equal(body.public, true); + assert.equal(Object.hasOwn(body, 'costs'), false); + for (const amount of [1234.56, 2345.67, 3456.78, 456.78, 567.89]) + assert.ok(!JSON.stringify(body).includes(String(amount))); + }; + await anonymous('/api/aws?as=9920871'); // Claimed identity never grants costs. + const csrf = await w.login(); + const signedIn = await (await w.req('/api/aws?as=public')).json(); + assert.equal(signedIn.public, true, 'sign-in does not grant detailed inventory'); + assert.deepEqual(signedIn.costs, costs, 'signed-in summaries retain all costs'); + await anonymous('/api/aws?as=42', { headers: { cookie: 'dash-session=invalid' } }); + assert.equal((await w.req('/api/auth/logout', { method: 'POST', headers: { 'x-csrf-token': csrf } })).status, 200); + await anonymous(); // Same inventory timestamp must not reuse signed-in costs. + } finally { w.close(); } +}); + test('console devnet connection files reach members only', async () => { const w = await start(); try { diff --git a/server/websites.js b/server/websites.js new file mode 100644 index 0000000..3491db0 --- /dev/null +++ b/server/websites.js @@ -0,0 +1,12 @@ +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; + +export function websiteReport(dataDir, now = Date.now()) { + let report; + try { report = JSON.parse(readFileSync(join(dataDir, 'websites', 'report.json'), 'utf8')); } catch { /* A missing collector is unknown, not healthy. */ } + const age = now - Date.parse(report?.generatedAt); + if (report?.schemaVersion !== 1 || !Array.isArray(report.sites)) { + return { stale: true, sites: [], error: 'Website checks have not reported yet.' }; + } + return { ...report, stale: !Number.isFinite(age) || age > 12 * 60_000 || age < -60_000 }; +} diff --git a/server/websites.test.js b/server/websites.test.js new file mode 100644 index 0000000..77e87e8 --- /dev/null +++ b/server/websites.test.js @@ -0,0 +1,33 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { websiteReport } from './websites.js'; +import { segments, recommendations } from '../src/website-metrics.js'; + +test('missing, stale and future data never appear fresh', () => { + const dir = mkdtempSync(join(tmpdir(), 'websites-')); + try { + assert.equal(websiteReport(dir).stale, true); + mkdirSync(join(dir, 'websites')); + const now = Date.now(); + for (const [offset, stale] of [[0, false], [-13 * 60_000, true], [120_000, true]]) { + writeFileSync(join(dir, 'websites/report.json'), JSON.stringify({ schemaVersion: 1, generatedAt: new Date(now + offset).toISOString(), sites: [] })); + assert.equal(websiteReport(dir, now).stale, stale); + } + } finally { rmSync(dir, { recursive: true }); } +}); + +test('chart breaks lines on failed checks and missing intervals; no invented zeroes', () => { + const at = (n, ok = true) => ({ at: new Date(n * 300_000).toISOString(), ok, ttfbMs: 100 }); + const result = segments([at(0), at(1), at(2, false), at(3), at(8)], 'ttfbMs', 0, 9 * 300_000); + assert.deepEqual(result.map((g) => g.length), [2, 1, 1]); + assert.ok(result.flat().every((s) => s.value === 100)); +}); + +test('recommendations are evidence-based and failures are not performance advice', () => { + assert.deepEqual(recommendations({ ok: false, error: 'TLS validation failed' }), ['TLS validation failed']); + assert.ok(recommendations({ ok: true, redirects: 1, redirectMs: 95 }).some((s) => s.includes('95 ms'))); + assert.ok(!recommendations({ ok: true, encoding: 'br', htmlBytes: 1000 }).some((s) => s.includes('not compressed'))); +}); diff --git a/shared/evaluate.js b/shared/evaluate.js index c4024af..fb67758 100644 --- a/shared/evaluate.js +++ b/shared/evaluate.js @@ -246,7 +246,7 @@ export function evaluateNetwork(network, state, settings, now = Date.now(), tags dapi: { ok: validatorRows.filter((r) => r.data.dapi?.ok).length, total: validatorRows.filter((r) => r.host.state === 'running').length }, }; if (network.chainType !== 'mainnet') summary.monitoring = monitoringSummary(rows, state?.endpoints || [], now); - const mainnetRow = rows.find((r) => r.host.role === 'fullnode' && r.data.mainnet); + const mainnetRow = rows.find((r) => ['fullnode', 'validator'].includes(r.host.role) && r.data.mainnet); if (network.chainType === 'mainnet' && mainnetRow) { const m = mainnetRow.data.mainnet || {}; summary.mainnet = { diff --git a/shared/mainnet.js b/shared/mainnet.js index d145777..733052e 100644 --- a/shared/mainnet.js +++ b/shared/mainnet.js @@ -1,10 +1,37 @@ // Public-data-only boundary. Failure samples are data, never manufactured health. const integer = (v) => Number.isSafeInteger(v) && v >= 0 ? v : null; const finite = (v) => Number.isFinite(v) && v >= 0 ? v : null; -const text = (v, max = 80) => typeof v === 'string' ? v.slice(0, max) : null; +const version = (v) => typeof v === 'string' && /^(?:unreleased-)?\d+(?:\.\d+){0,2}(?:[-+][a-zA-Z0-9.-]+)?$/.test(v) && v.length < 64 ? v : null; +const coreVersion = (v) => typeof v === 'string' && /^\/Dash Core:\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?\/$/.test(v) ? v : null; +const enumeration = (v, allowed) => allowed.includes(v) ? v : null; const boolean = (v) => typeof v === 'boolean' ? v : null; const timestamp = (v) => typeof v === 'string' && Number.isFinite(Date.parse(v)) ? new Date(v).toISOString() : null; +const SERVICES = { + quorums: ['Quorums · fresh Core comparison', 'https://quorums.mainnet.networks.dash.org/quorums'], + insight: ['Insight · indexed block/transaction', 'https://insight.dash.org/insight/'], + 'seed-1': ['Platform seed 1 · TLS + bootstrap', 'https://seed-1.mainnet.networks.dash.org'], + 'seed-2': ['Platform seed 2 · TLS + bootstrap', 'https://seed-2.mainnet.networks.dash.org'], + 'seed-3': ['Platform seed 3 · TLS + bootstrap', 'https://seed-3.mainnet.networks.dash.org'], + bootstrap: ['Default SDK bootstrap', 'https://www.npmjs.com/package/@dashevo/dapi-client'], + 'quorums-tls': ['Quorum certificate', 'https://quorums.mainnet.networks.dash.org'], + 'insight-tls': ['Insight certificate', 'https://insight.dash.org'], + observer: ['Independent observer / data freshness', 'https://status.testnet.networks.dash.org/'], + core: ['Core chain progress', 'https://status.testnet.networks.dash.org/'], platform: ['Platform chain progress', 'https://status.testnet.networks.dash.org/'], chainlocks: ['ChainLocks', 'https://status.testnet.networks.dash.org/'], +}; +export function serviceEndpoints(input, now) { + const fresh = finite(input?.at) !== null && now / 1000 - input.at >= -60 && now / 1000 - input.at <= 240; + const rows = Array.isArray(input?.services) ? input.services : []; + return Object.entries(SERVICES).map(([id, [label, url]]) => { + const samples = rows.filter((s) => s?.id === id); + const s = fresh && samples.length === 1 ? samples[0] : null; + const reason = enumeration(s?.reason, ['healthy', 'reference-unavailable', 'stale-data', 'certificate-expiring', 'probe-failed', 'consensus-signal']); + return { label, url, kind: 'mainnet-service', ok: s ? boolean(s.ok) : false, + status: s?.ok === true ? 'OK' : null, ms: finite(s?.ms), height: integer(s?.height), + error: s?.ok === true ? null : reason || 'monitor sample missing or stale' }; + }); +} + export function validateMainnetReport(input, now = Date.now()) { if (!input || input.network !== 'mainnet') throw new Error('mainnet report required'); const at = timestamp(input.generatedAt); @@ -15,16 +42,41 @@ export function validateMainnetReport(input, now = Date.now()) { const c = input.core; core = { chain: 'main', blocks: c.blocks, headers: integer(c.headers), chainLockHeight: integer(c.chainLockHeight), bestBlockHash: /^[a-f0-9]{64}$/i.test(c.bestBlockHash || '') ? c.bestBlockHash : null, - blockTime: finite(c.blockTime), ibd: boolean(c.ibd), synced: boolean(c.synced), - subversion: text(c.subversion), protocol: integer(c.protocol), connections: integer(c.connections) }; + blockTime: finite(c.blockTime), difficulty: finite(c.difficulty), ibd: boolean(c.ibd), synced: boolean(c.synced), + subversion: coreVersion(c.subversion), protocol: integer(c.protocol), connections: integer(c.connections) }; } let platform = null; if (input.platform != null) { const p = input.platform; if (p.network !== 'evo1' || integer(p.height) === null) throw new Error('mainnet Platform chain and height required'); platform = { height: p.height, blockTime: timestamp(p.blockTime), network: p.network, - catchingUp: boolean(p.catchingUp), maxPeerHeight: integer(p.maxPeerHeight), peers: integer(p.peers), version: text(p.version) }; + catchingUp: boolean(p.catchingUp), maxPeerHeight: integer(p.maxPeerHeight), peers: integer(p.peers), version: version(p.version), protocolApp: integer(p.protocolApp), validatorSetSize: integer(p.validatorSetSize), round: integer(p.round), commitRound: integer(p.commitRound), thresholdSigned: boolean(p.thresholdSigned) }; } + // Explicit schema on ingress: no target/address, ProTx/node ID, payment height, + // certificate identity, arbitrary error, container name or untrusted text survives. + const evo = input.evo === true; + const mn = input.core?.masternode; + if (core && evo && mn) core.masternode = { + state: enumeration(mn.state, ['READY', 'WAITING_FOR_PROTX', 'POSE_BANNED', 'REMOVED', 'ERROR']), + type: enumeration(mn.type, ['Evo']), posePenalty: integer(mn.posePenalty), + }; + const d = input.dapi; + const dapi = evo ? { + ok: d?.ok === true, latencyMs: finite(d?.latencyMs), height: integer(d?.height), + dapiVersion: version(d?.dapiVersion), driveVersion: version(d?.driveVersion), + chainId: d?.chainId === 'evo1' ? 'evo1' : null, + query: d?.query ? { ok: d.query.ok === true, method: 'getEpochsInfo', + latencyMs: finite(d.query.latencyMs), epoch: integer(d.query.epoch), + firstBlockHeight: integer(d.query.firstBlockHeight), protocol: integer(d.query.protocol) } : null, + } : null; + const components = { core: 'dashpay/dashd', drive: 'dashpay/drive', tenderdash: 'dashpay/tenderdash', dapi: 'dashpay/rs-dapi' }; + const containers = evo ? Object.entries(components).flatMap(([component, repo]) => { + const c = input.components?.[component]; + const tag = version(c?.version); + return c && tag ? [{ name: component, service: component, repo, image: `${repo}:${tag}`, + running: c.running === true, state: c.running === true ? 'running' : 'unavailable', + restarts: integer(c.restarts) }] : []; + }) : []; const q = input.quorumServer; const quorum = q && typeof q === 'object' ? Object.fromEntries(['status', 'quorums', 'listed', 'banned', 'enabled', 'versionFailures'].map((k) => [k, integer(q[k])])) : null; if (quorum) quorum.latencyMs = finite(q.latencyMs); @@ -34,8 +86,8 @@ export function validateMainnetReport(input, now = Date.now()) { quorumServer: quorum, coreStall: core?.ibd === false ? boolean(input.mainnet?.coreStall) : null, platformStall: platform?.catchingUp === false ? boolean(input.mainnet?.platformStall) : null }; return { network: 'mainnet', generatedAt: at, pollSeconds: 60, discovery: { at, error: null }, - endpoints: [{ label: 'Quorum list', kind: 'quorum', url: 'https://quorums.mainnet.networks.dash.org/masternodes', + endpoints: input.serviceChecks !== undefined ? serviceEndpoints(input.serviceChecks, now) : [{ label: 'Quorum list', kind: 'quorum', url: 'https://quorums.mainnet.networks.dash.org/masternodes', status: quorum?.status ?? null, ok: quorum?.status === 200 && quorum.quorums > 0 && quorum.listed > 0, ms: quorum?.latencyMs ?? null }], - hosts: [{ name: 'mainnet-observer', role: 'fullnode', state: 'running', publicIp: null, privateIp: null, - probe: { ok: true, at, ms: finite(input.probeMs) ?? 0, data: { core, tenderdash: platform, mainnet, containers: [], system: null } } }] }; + hosts: [{ name: 'mainnet-observer', role: evo ? 'validator' : 'fullnode', state: 'running', publicIp: null, privateIp: null, + probe: { ok: true, at, ms: finite(input.probeMs) ?? 0, data: { core, tenderdash: platform, mainnet, dapi, containers, system: null } } }] }; } diff --git a/shared/mainnet.test.js b/shared/mainnet.test.js index 9456f81..e4f6e71 100644 --- a/shared/mainnet.test.js +++ b/shared/mainnet.test.js @@ -2,7 +2,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; import { validateMainnetReport } from './mainnet.js'; -import { evaluateNetwork } from './evaluate.js'; +import { evaluateNetwork, projectNetwork } from './evaluate.js'; import { DEFAULT_SETTINGS, validateSettings } from './settings.js'; const now = Date.parse('2026-09-30T08:00:00Z'); @@ -52,3 +52,64 @@ test('mainnet-support cannot enter EC2 discovery, even with malformed legacy set const bad = structuredClone(DEFAULT_SETTINGS); bad.networks[bad.networks.findIndex((n) => n.name === 'mainnet')] = forbidden; assert.throws(() => validateSettings(bad), /separate report observer/); }); + +test('private Evo fills dashboard metrics without disclosing source identity in state or projection', () => { + const r = fixture(); r.evo = true; r.core.difficulty = 123.25; + const privateValue = 'PRIVATE-NODE-IDENTITY'; + r.publicIp = privateValue; + r.core.masternode = { state: 'READY', type: 'Evo', posePenalty: 0, proTxHash: privateValue, + service: privateValue, lastPaidHeight: 123456, registeredHeight: 123456 }; + Object.assign(r.platform, { protocolApp: 13, validatorSetSize: 100, peers: 8, nodeId: privateValue, proTxHash: privateValue, proposer: privateValue }); + r.dapi = { ok: true, height: 200, dapiVersion: '4.1.1', driveVersion: '4.1.2', chainId: 'evo1', error: privateValue, + tls: { issuer: privateValue }, query: { ok: true, epoch: 300, protocol: 13, error: privateValue } }; + r.components = { drive: { version: '4.1.2', running: true, restarts: 0, name: privateValue } }; + const normalized = validateMainnetReport(r, now); + const publicView = projectNetwork(DEFAULT_SETTINGS.networks.find((n) => n.name === 'mainnet'), evaluate(r), normalized, false); + assert.doesNotMatch(JSON.stringify([normalized, publicView]), /PRIVATE-NODE-IDENTITY|123456/); + assert.equal(publicView.summary.core.difficulty, 123.25); + assert.equal(publicView.summary.mainnet.bigBans, 876); + assert.equal(publicView.summary.mainnet.quorumCount, 20); + assert.equal(publicView.summary.mainnet.coreStall, false); + assert.equal(publicView.summary.platform.protocol, 13); + assert.equal(publicView.summary.platform.validatorSet, 100); + assert.deepEqual(publicView.summary.masternodes, { ready: 1, total: 1, pose: 0 }); + assert.deepEqual(publicView.summary.dapi, { ok: 1, total: 1 }); + assert.equal(publicView.summary.versions.drive['4.1.2'], 1); + assert.equal(publicView.hosts[0].publicIp, null); +}); + +test('configured private Evo failure cannot manufacture readiness or DAPI health from fallback', () => { + const r = fixture(); r.evo = true; + const view = evaluate(r); + assert.equal(view.level, 'down'); + assert.equal(view.summary.masternodes.ready, 0); + assert.equal(view.summary.dapi.ok, 0); + assert.equal(view.summary.core.height, 100); + assert.equal(view.summary.platform.height, 200); +}); + +test('private text in allowed-looking fields is rejected before persistence', () => { + const r = fixture(); r.evo = true; + r.core.subversion = 'PRIVATE-NODE-IDENTITY'; r.platform.version = '192.0.2.123'; + r.core.masternode = { state: 'PRIVATE-NODE-IDENTITY', type: '192.0.2.123' }; + r.dapi = { driveVersion: 'PRIVATE-NODE-IDENTITY', chainId: 'PRIVATE-NODE-IDENTITY' }; + r.components = { drive: { version: '192.0.2.123', running: true } }; + assert.doesNotMatch(JSON.stringify(validateMainnetReport(r, now)), /PRIVATE-NODE-IDENTITY|192\.0\.2\.123/); +}); + +test('service projection allowlists identity, fails stale/missing samples, preserves unknown', () => { + const r = fixture(); + r.serviceChecks = { at: now/1000, services: [{ id: 'insight', ok: true, ms: 3, height: 100, password: 'SECRET' }, + { id: 'quorums', ok: false, reason: 'stale-data', url: 'https://SECRET' }, { id: 'observer', ok: null, reason: 'SECRET' }] }; + let endpoints = validateMainnetReport(r,now).endpoints; + assert.equal(endpoints.find(e=>e.label.startsWith('Insight ·')).ok,true); + assert.equal(endpoints.find(e=>e.label.startsWith('Quorums ·')).ok,false); + assert.equal(endpoints.find(e=>e.label.startsWith('Independent')).ok,null); + assert.equal(endpoints.find(e=>e.label.startsWith('Platform seed 1')).ok,false); + assert.doesNotMatch(JSON.stringify(endpoints),/SECRET/); + assert.ok(endpoints.every(e=>typeof e.url==='string' && e.url.startsWith('https://'))); + assert.equal(endpoints.find(e=>e.label.startsWith('Insight ·')).status,'OK'); + r.serviceChecks.at -= 241; + endpoints = validateMainnetReport(r,now).endpoints; + assert.ok(endpoints.every(e=>e.ok===false)); +}); diff --git a/src/App.jsx b/src/App.jsx index 997faef..4f85b6c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -9,6 +9,7 @@ import Settings from './pages/Settings.jsx'; import NewDevnet from './pages/NewDevnet.jsx'; import ResetPlatform from './pages/ResetPlatform.jsx'; import CI from './pages/CI.jsx'; +import Websites from './pages/Websites.jsx'; import Queue from './pages/Queue.jsx'; import Aws from './pages/Aws.jsx'; import Remediation from './pages/Remediation.jsx'; @@ -28,6 +29,7 @@ export default function App() { else if (parts[0] === 'settings') page = ; else if (parts[0] === 'ci' && parts[1] === 'queue') page = ; else if (parts[0] === 'ci') page = ; + else if (parts[0] === 'websites') page = ; else if (parts[0] === 'aws') page = ; else if (parts[0] === 'remediation') page = ; else if (parts[0] === 'devnets' && parts[1] === 'new') page = ; @@ -60,6 +62,7 @@ function Header({ networks, active, session }) { {<>