diff --git a/platform/packages/api/src/admin/react/styles.css b/platform/packages/api/src/admin/react/styles.css index f4b4771ca..34ca83bae 100644 --- a/platform/packages/api/src/admin/react/styles.css +++ b/platform/packages/api/src/admin/react/styles.css @@ -826,6 +826,14 @@ body { max-width: none; white-space: nowrap; } +/* Short identifiers (finding IDs, project slugs) stay on one line; long columns wrap instead. */ +.void-admin-nowrap { + white-space: nowrap; +} +.void-admin-content td:has(.void-admin-nowrap) { + max-width: none; + white-space: nowrap; +} .void-admin-projects-table { min-width: 58rem; } diff --git a/platform/packages/api/src/admin/react/views/FormControls.tsx b/platform/packages/api/src/admin/react/views/FormControls.tsx index 860ccdbab..b3272cb86 100644 --- a/platform/packages/api/src/admin/react/views/FormControls.tsx +++ b/platform/packages/api/src/admin/react/views/FormControls.tsx @@ -172,6 +172,7 @@ export function FormNumberInput({ min = 1, max, required = false, + units, }: { label: string; name: string; @@ -180,6 +181,8 @@ export function FormNumberInput({ min?: number; max?: number; required?: boolean; + /** Unit text shown at the end of the input, e.g. `minutes`. */ + units?: string; }) { const [value, setValue] = useResettableState(initialValue); return ( @@ -195,6 +198,7 @@ export function FormNumberInput({ isIntegerOnly hasClear width={width} + units={units} /> ); } diff --git a/platform/packages/api/src/admin/react/views/SecurityPage.tsx b/platform/packages/api/src/admin/react/views/SecurityPage.tsx index bfd25f1ce..52fbfbe01 100644 --- a/platform/packages/api/src/admin/react/views/SecurityPage.tsx +++ b/platform/packages/api/src/admin/react/views/SecurityPage.tsx @@ -316,14 +316,15 @@ function SettingsSection({ label="Scans at once" name="concurrency" initialValue={settings.limits.concurrency} - width={160} + width={200} required /> @@ -423,10 +424,12 @@ function FindingsSection({ {findings.findings.map((finding) => ( - {finding.id} + + {finding.id} + {finding.project} @@ -570,7 +573,7 @@ function ScansSection({ {scan.project} @@ -658,7 +661,7 @@ function RequestsSection({ {request.project} @@ -710,7 +713,7 @@ function RequestsSection({ {bypass.project} diff --git a/platform/packages/api/test/integration/admin-security.test.ts b/platform/packages/api/test/integration/admin-security.test.ts index 61c31e048..82a886ccf 100644 --- a/platform/packages/api/test/integration/admin-security.test.ts +++ b/platform/packages/api/test/integration/admin-security.test.ts @@ -1,7 +1,9 @@ +import { readFile } from 'node:fs/promises'; import { DEFAULT_SECURITY_MODEL, SECURITY_MODEL_IDS } from '@void/platform/security-models'; import { defaultSecurityPolicy } from '@void/platform/security-policy'; import type { SecurityPolicy } from '@void/platform/security-policy'; import { eq } from 'drizzle-orm'; +import { chromium } from 'playwright'; import { afterAll, afterEach, @@ -15,6 +17,7 @@ import { import { app } from '../../src/index.ts'; import { operatorEvents, + projects, projectZeroTrust, securityFindings, securityPublicRequests, @@ -192,4 +195,85 @@ describe('admin security pages', () => { .where(eq(projectZeroTrust.project_id, project.id)); expect(zt?.desired_protected).toBe(true); }); + it('keeps finding IDs, project slugs and the limit inputs on one line', async () => { + const s = await setupGate(env); + await askPublic(s); + await env.db + .update(projects) + .set({ slug: 'sa-callcap-55118' }) + .where(eq(projects.id, s.project.id)); + await env.db.insert(securityFindings).values({ + id: 'sf_wrap', + project_id: s.project.id, + number: 3, + fingerprint_key: 'fp-wrap', + verdict: 'confirmed', + severity: 'high', + title: + 'Unauthenticated GET /api/users returns every user record (names, emails) and POST /api/users inserts rows into D1', + category: 'auth', + file: 'routes/api/users/index.ts', + line_start: 6, + first_scan_id: 'ss_x', + last_seen_scan_id: 'ss_x', + }); + const assets = new URL('../../dist/admin-assets/admin/', import.meta.url); + const client = await readFile(new URL('client.js', assets)); + const css = await readFile(new URL('style.css', assets)); + const browser = await chromium.launch(); + try { + for (const width of [1280, 390]) { + const context = await browser.newContext({ viewport: { width, height: 844 } }); + await context.addCookies([{ name: 'admin_token', value: cookie, url: 'http://localhost' }]); + const page = await context.newPage(); + await page.route('**/*', async (route) => { + const url = new URL(route.request().url()); + if (url.origin !== 'http://localhost') { + return route.abort(); + } + if (url.pathname === '/admin/client.js' || url.pathname === '/admin/style.css') { + const js = url.pathname.endsWith('.js'); + return route.fulfill({ + contentType: js ? 'text/javascript' : 'text/css', + body: js ? client : css, + }); + } + const response = await app.fetch( + new Request(url, { headers: await route.request().allHeaders() }), + onEnv, + ); + await route.fulfill({ + status: response.status, + headers: Object.fromEntries(response.headers), + body: (Buffer as BufferConstructor).from(await response.arrayBuffer()), + }); + }); + const open = async (path: string) => { + await page.goto(`http://localhost/admin/security${path}`); + }; + const lines = (text: string) => + page + .getByText(text, { exact: true }) + .first() + .evaluate((node) => node.getClientRects().length); + await open(''); + const concurrency = (await page + .getByRole('spinbutton', { name: 'Scans at once' }) + .boundingBox())!; + const timeout = (await page.getByRole('spinbutton', { name: 'Timeout' }).boundingBox())!; + if (width === 1280) { + // Side by side on a wide screen; on a phone the row wraps and the inputs stack. + expect(timeout.y).toBeCloseTo(concurrency.y, 0); + } + await open('/findings'); + expect(await lines('F-3')).toBe(1); + expect(await lines('sa-callcap-55118')).toBe(1); + await open('/requests'); + expect(await lines('sa-callcap-55118')).toBe(1); + await context.close(); + } + } finally { + await browser.close(); + } + }, 60_000); });