Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
437 changes: 374 additions & 63 deletions apps/web/src/app/globals.css

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import type { Metadata } from 'next';
import { Bricolage_Grotesque, JetBrains_Mono } from 'next/font/google';
import type { ReactNode } from 'react';
import { SiteFooter } from './site-chrome.tsx';
import './globals.css';

const sans = Bricolage_Grotesque({ subsets: ['latin'], variable: '--font-sans' });
const mono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-mono' });

export const metadata: Metadata = {
title: 'stackprobe',
description: 'See what a product is built on, with the evidence for every finding.',
};

export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<html lang="en" className={`${sans.variable} ${mono.variable}`}>
<body>
<main>
<a href="/" className="brand">
stackprobe
</a>
{children}
</main>
{children}
<SiteFooter />
</body>
</html>
);
Expand Down
18 changes: 12 additions & 6 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { ScanForm } from './scan-form.tsx';
import { SiteHeader } from './site-chrome.tsx';

export default function Home() {
return (
<>
<h1>What is it built on?</h1>
<p className="muted">
Type a domain or URL. stackprobe shows the technologies it finds, with the evidence and a
confidence score for each.
</p>
<ScanForm />
<SiteHeader />
<main className="page home">
<section className="home-hero">
<h1>What's it built on?</h1>
<p>
The product, not the landing page. Each finding comes with the headers, requests and
code that show it.
</p>
<ScanForm />
</section>
</main>
</>
);
}
20 changes: 20 additions & 0 deletions apps/web/src/app/s/[domain]/copy-link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use client';

import { useState } from 'react';

export function CopyLink() {
const [copied, setCopied] = useState(false);
return (
<button
type="button"
className="link-button"
onClick={async () => {
await navigator.clipboard.writeText(window.location.href.split('?')[0] ?? '');
setCopied(true);
setTimeout(() => setCopied(false), 2000);
}}
>
{copied ? 'Copied' : 'Copy link'}
</button>
);
}
180 changes: 15 additions & 165 deletions apps/web/src/app/s/[domain]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,188 +1,38 @@
import {
type Detection,
detectionsWithFolded,
type Folded,
type Report,
type ScanRecord,
type Surface,
surfacesByRole,
} from '@drippa/stackprobe-core';
import type { Metadata } from 'next';
import { getStore } from '../../../lib/services.ts';
import { rescanAction } from '../../actions.ts';
import { ScanForm } from '../../scan-form.tsx';
import { AutoRefresh } from './auto-refresh.tsx';
import { SiteHeader } from '../../site-chrome.tsx';
import { NotScanned, ReportView, Running } from './report-sections.tsx';

interface Props {
params: Promise<{ domain: string }>;
searchParams: Promise<{ surface?: string }>;
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { domain } = await params;
return { title: `${decodeURIComponent(domain)} · stackprobe` };
}

export default async function ScanPage({ params }: Props) {
export default async function ScanPage({ params, searchParams }: Props) {
const domain = decodeURIComponent((await params).domain).toLowerCase();
const { surface } = await searchParams;
const scan = await getStore().latestScan(domain);

if (!scan) {
return (
<>
<h1>{domain}</h1>
<p className="muted">Not scanned yet.</p>
<ScanForm defaultValue={domain} />
</>
);
}

return (
<>
<h1>{scan.domain}</h1>
<ScanStatusLine scan={scan} />
{scan.status === 'running' ? <AutoRefresh /> : null}
{scan.report ? <ReportView report={scan.report} /> : null}
</>
);
}

function ScanStatusLine({ scan }: { scan: ScanRecord }) {
if (scan.status === 'running') {
return <p className="muted">Scanning {scan.url} …</p>;
}
return (
<>
<p className="muted">
Scanned {scan.url} on {formatDate(scan.finishedAt ?? scan.createdAt)}.
{scan.status === 'partial' ? (
<span className="warn"> Some checks failed, so this result may be incomplete.</span>
) : null}
</p>
<form action={rescanAction} className="scan">
<input type="hidden" name="url" value={scan.url} />
<button type="submit">Scan again</button>
</form>
</>
);
}

// Product first: marketing findings never stand in for the product's stack.
function ReportView({ report }: { report: Report }) {
const { product, marketing, other, folded } = surfacesByRole(report);
return (
<>
<section>
<h2>Product</h2>
{product.length > 0 ? null : marketing.length > 0 ? (
<p className="warn">No product app found; showing the marketing site only.</p>
<SiteHeader>
<ScanForm variant="compact" />
</SiteHeader>
<main className="page report">
{!scan ? (
<NotScanned domain={domain} />
) : scan.report ? (
<ReportView scan={scan} report={scan.report} selected={surface} />
) : (
<p className="warn">
Couldn't tell which of these is the product app, so nothing is shown as the product.
</p>
<Running scan={scan} />
)}
</section>
{[...product, ...marketing, ...other].map((surface) => (
<SurfaceView key={surface.id} surface={surface} folded={folded[surface.id] ?? []} />
))}
<section>
<h2>Checks run</h2>
<ul>
{report.layersRun.map((run) => (
<li key={`${run.surfaceId} ${run.layer}`}>
{run.layer.toUpperCase()}: {run.status}
{run.error ? <span className="muted"> ({run.error.message})</span> : null}
</li>
))}
</ul>
<p className="muted">Fingerprints version {report.fingerprintsVersion}.</p>
</section>
</main>
</>
);
}

const SURFACE_LABELS: Record<Surface['kind'], string> = {
unclassified: 'Not sure what this is',
marketing: 'Marketing site',
app: 'Product app',
api: 'API',
docs: 'Docs',
status: 'Status page',
auth: 'Sign-in',
other: 'Other',
};

const FOUND_BY = (foundBy: NonNullable<Surface['foundBy']>) =>
foundBy.kind === 'subdomain'
? 'Found as a subdomain.'
: foundBy.text
? `Found via the “${foundBy.text}” link.`
: 'Found via a link.';

function SurfaceView({ surface, folded }: { surface: Surface; folded: Folded[] }) {
const detections = detectionsWithFolded(surface, folded);
return (
<section>
<h2>
<code>{surface.url}</code>
</h2>
<p className="muted">
<strong>{SURFACE_LABELS[surface.kind]}</strong>
{surface.kindConfidence !== null ? ` (${Math.round(surface.kindConfidence * 100)}%)` : ''}
{surface.kindReasons?.length ? `: ${surface.kindReasons.join(', ')}.` : '.'}
{surface.foundBy ? ` ${FOUND_BY(surface.foundBy)}` : ''}
</p>
{folded.length > 0 ? (
<p className="muted">
Also:{' '}
{folded
.map(({ surface: s, reason }) =>
reason === 'redirect' ? `${s.url} redirects here` : `${s.url} (same app)`,
)
.join('; ')}
.
</p>
) : null}
{detections.length === 0 ? (
<p>Nothing detected here yet.</p>
) : (
<ul className="detections">
{detections.map((detection) => (
<DetectionView key={detection.tech} detection={detection} />
))}
</ul>
)}
</section>
);
}

function DetectionView({ detection }: { detection: Detection }) {
return (
<li>
<div className="detection-head">
<strong>
{detection.tech}
{detection.version ? ` ${detection.version}` : ''}
</strong>
<span title="Confidence">{Math.round(detection.confidence * 100)}%</span>
</div>
<div className="muted">{detection.category}</div>
<details>
<summary>Evidence ({detection.evidence.length})</summary>
<ul>
{detection.evidence.map((evidence) => (
<li key={`${evidence.ruleId} ${evidence.detail}`}>
<code>{evidence.detail}</code>{' '}
<span className="muted">
{evidence.type} by {evidence.layer.toUpperCase()}
</span>
</li>
))}
</ul>
</details>
</li>
);
}

function formatDate(iso: string): string {
return new Date(iso).toUTCString();
}
113 changes: 113 additions & 0 deletions apps/web/src/app/s/[domain]/report-sections.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import type { Detection, Report, ScanRecord } from '@drippa/stackprobe-core';
import { renderToStaticMarkup } from 'react-dom/server';
import { describe, expect, test, vi } from 'vitest';
import { NotScanned, ReportView, Running } from './report-sections.tsx';

// Refreshing needs Next's router; rendering the running state doesn't.
vi.mock('./auto-refresh.tsx', () => ({ AutoRefresh: () => null }));

const det = (tech: string, confidence: number, version: string | null = null): Detection => ({
tech,
category: tech === 'clerk' ? 'auth' : 'hosting',
version,
confidence,
evidence: [
{ type: 'observed', layer: 'http', ruleId: `${tech}/a`, detail: `${tech} header`, weight: 0.9 },
{
type: 'observed',
layer: 'browser',
ruleId: `${tech}/b`,
detail: `${tech} request`,
weight: 0.8,
},
],
});

const report: Report = {
schemaVersion: '1',
domain: 'acme.test',
scannedAt: '2026-10-05T11:30:00.000Z',
fingerprintsVersion: 'abc123',
surfaces: [
{
id: 'root',
url: 'https://acme.test/',
kind: 'marketing',
kindConfidence: 0.9,
detections: [det('framer', 0.95)],
},
{
id: 'app',
url: 'https://app.acme.test/login',
kind: 'app',
kindConfidence: 0.97,
foundBy: { kind: 'link', text: 'Log in' },
detections: [det('clerk', 0.99, '5'), det('vercel', 0.95)],
},
],
layersRun: [
{ layer: 'http', surfaceId: 'root', status: 'ok', durationMs: 1 },
{ layer: 'browser', surfaceId: 'app', status: 'ok', durationMs: 1 },
],
};

const scan: ScanRecord = {
id: 'scan-1',
domain: 'acme.test',
url: 'https://acme.test/',
status: 'done',
createdAt: '2026-10-05T11:30:00.000Z',
finishedAt: '2026-10-05T11:30:26.000Z',
report,
};

const render = (selected?: string) =>
renderToStaticMarkup(<ReportView scan={scan} report={report} selected={selected} />);

describe('ReportView', () => {
test('opens with the domain, the product stack and the scan facts', () => {
const html = render();
expect(html).toContain('<h1>acme.test</h1>');
expect(html).toContain('Product runs on Clerk 5 and Vercel.');
expect(html).toContain('26 s');
});

test('tabs are links, product first, the current one marked', () => {
const tabs = [
...render().matchAll(/<a href="\?surface=([^"]+)"( aria-current="page")?>([^<]+)<\/a>/g),
];
expect(tabs.map((t) => [t[1], Boolean(t[2]), t[3]])).toEqual([
['app', true, 'Product app'],
['root', false, 'Marketing site'],
]);
const marketing = [...render('root').matchAll(/aria-current="page">([^<]+)</g)].map(
(m) => m[1],
);
expect(marketing).toEqual(['Marketing site']);
});

test('each technology is a row whose evidence opens in place', () => {
const html = render();
expect(html.match(/<details>/g)).toHaveLength(2);
expect(html).toContain('width:99%');
expect(html).toContain('clerk header');
expect(html).toContain('via the &quot;Log in&quot; link');
expect(html).not.toContain('framer header');
});

test('says which checks ran and offers copy and scan again', () => {
const html = render();
expect(html).toContain('Checks that ran: HTTP and a real browser.');
expect(html).toContain('Copy link');
expect(html).toContain('Scan again');
});
});

test('not scanned yet, and still scanning', () => {
expect(renderToStaticMarkup(<NotScanned domain="new.test" />)).toContain('Not scanned yet.');
const running = renderToStaticMarkup(
<Running scan={{ ...scan, status: 'running', report: null, finishedAt: null }} />,
);
expect(running).toContain('role="status"');
expect(running).toContain('Scanning https://acme.test/');
});
Loading
Loading