Skip to content

Full Audit

The security.audit() method runs all checks at once and returns a structured report. It’s available through the security fixture.

import { test, expect } from "@orlalabs/kovar";
test("full security audit", async ({ page, security }) => {
await page.goto("/dashboard");
const report = await security.audit();
expect(report.summary.critical).toBe(0);
expect(report.summary.high).toBe(0);
});

The audit returns a SecurityReport object:

{
url: "https://...",
timestamp: "2026-03-22T...",
duration: 142,
findings: SecurityFinding[],
summary: { total, critical, high, medium, low, info }
}

See SecurityFinding for the full type definition.

XSS testing is opt-in because it’s slower than other checks:

const report = await security.audit({
includeXSS: true,
xss: { selector: "#search-form", depth: "standard" },
headers: { skip: ["permissions-policy"] },
cookies: { maxExpiryDays: 180 },
});

By default, the audit runs headers and cookies. CSRF, CORS, auth, and accessibility are opt-in. Use the checks option to specify exactly which checks to run:

const report = await security.audit({
checks: ["headers", "cookies", "csrf", "cors", "auth", "accessibility"],
csrf: { methods: ["POST", "DELETE"] },
cors: { dangerousOrigins: ["http://evil.com"] },
auth: { endpoints: ["/api/admin/users", "/api/admin/settings"] },
accessibility: { includeWarnings: true },
});
OptionTypeDescription
checksstring[]Which checks to run (default: ["headers", "cookies"])
includeXSSbooleanInclude XSS testing (default: false)
headersobjectOptions passed to headers check
cookiesobjectOptions passed to cookies check
xssobjectOptions passed to XSS check
csrfobjectOptions passed to CSRF check
corsobjectOptions passed to CORS check
authobjectOptions passed to auth check
accessibilityobjectOptions passed to accessibility check

All findings from the audit are automatically attached as JSON to the Playwright test report. The Kovar reporter aggregates these across your test suite to produce a security score card.