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
8 changes: 8 additions & 0 deletions platform/packages/api/src/admin/react/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions platform/packages/api/src/admin/react/views/FormControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export function FormNumberInput({
min = 1,
max,
required = false,
units,
}: {
label: string;
name: string;
Expand All @@ -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 (
Expand All @@ -195,6 +198,7 @@ export function FormNumberInput({
isIntegerOnly
hasClear
width={width}
units={units}
/>
);
}
19 changes: 11 additions & 8 deletions platform/packages/api/src/admin/react/views/SecurityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,15 @@ function SettingsSection({
label="Scans at once"
name="concurrency"
initialValue={settings.limits.concurrency}
width={160}
width={200}
required
/>
<FormNumberInput
label="Timeout (minutes)"
label="Timeout"
name="timeoutMinutes"
initialValue={settings.limits.timeoutMinutes}
width={160}
width={200}
units="minutes"
required
/>
</div>
Expand Down Expand Up @@ -423,10 +424,12 @@ function FindingsSection({
<TableBody>
{findings.findings.map((finding) => (
<TableRow key={`${finding.projectId}:${finding.id}`}>
<TableCell>{finding.id}</TableCell>
<TableCell>
<span className="void-admin-nowrap">{finding.id}</span>
</TableCell>
<TableCell>
<a
className="void-admin-resource-link"
className="void-admin-resource-link void-admin-nowrap"
href={`/admin/projects/${finding.projectId}#security`}
>
{finding.project}
Expand Down Expand Up @@ -570,7 +573,7 @@ function ScansSection({
</TableCell>
<TableCell>
<a
className="void-admin-resource-link"
className="void-admin-resource-link void-admin-nowrap"
href={`/admin/projects/${scan.projectId}#security`}
>
{scan.project}
Expand Down Expand Up @@ -658,7 +661,7 @@ function RequestsSection({
<TableRow key={request.id}>
<TableCell>
<a
className="void-admin-resource-link"
className="void-admin-resource-link void-admin-nowrap"
href={`/admin/projects/${request.projectId}#zero-trust`}
>
{request.project}
Expand Down Expand Up @@ -710,7 +713,7 @@ function RequestsSection({
<TableRow key={bypass.id}>
<TableCell>
<a
className="void-admin-resource-link"
className="void-admin-resource-link void-admin-nowrap"
href={`/admin/projects/${bypass.projectId}#zero-trust`}
>
{bypass.project}
Expand Down
84 changes: 84 additions & 0 deletions platform/packages/api/test/integration/admin-security.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,6 +17,7 @@ import {
import { app } from '../../src/index.ts';
import {
operatorEvents,
projects,
projectZeroTrust,
securityFindings,
securityPublicRequests,
Expand Down Expand Up @@ -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);
});