Skip to content

feat: Add responseHeaderReport for evaluating and recommending security headers - #59

Merged
foxable merged 1 commit into
mainfrom
feat/response-header-report
Oct 19, 2026
Merged

foxable merged 1 commit into
mainfrom
feat/response-header-report

Conversation

@foxable

@foxable foxable commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Adds responseHeaderReport, which evaluates the headers of a response against recommended security headers and renders the result as a Markdown report for file snapshots. The type option selects the recommendations: document for HTML documents, or api for other responses such as REST or GraphQL endpoints. The report lists the detected security headers, then recommends adding missing headers, changing values that deviate and removing discouraged headers. Values are compared ignoring case and whitespace, and stricter values are accepted. Unrelated headers like date are left out and CSP nonces are masked, so the report stays deterministic. Also adds getResponseHeaders, which extracts the headers from a page response or an APIRequestContext response.

Stacked on #58.

Example

import {
  getResponseHeaders,
  responseHeaderReport,
} from "@cronn/playwright-utils";
import { expect, test } from "@playwright/test";

test("has secure response headers", async ({ page }) => {
  const response = await page.goto("/");
  const headers = await getResponseHeaders(response);

  expect(responseHeaderReport(headers, { type: "document" })).toMatchTextFile({
    fileExtension: "md",
  });
});
## Recommendations

- `strict-transport-security`: Change to `max-age=31536000; includeSubDomains`
- `x-frame-options`: Change to `DENY`

@foxable foxable self-assigned this Oct 8, 2026
@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ee217c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cronn/playwright-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@foxable
foxable force-pushed the feat/response-header-report branch from c01ba1a to 174bab7 Compare October 8, 2026 10:37
@foxable
foxable force-pushed the feat/csp-report branch 5 times, most recently from 9bd0712 to 45a461a Compare October 13, 2026 08:36
Base automatically changed from feat/csp-report to main October 14, 2026 08:36
@foxable
foxable force-pushed the feat/response-header-report branch from 174bab7 to 1b1580d Compare October 14, 2026 08:43
@PMudra
PMudra self-requested a review October 16, 2026 14:36
@foxable
foxable force-pushed the feat/response-header-report branch from 1b1580d to ee217c3 Compare October 19, 2026 06:34
@foxable
foxable merged commit 892aa3c into main Oct 19, 2026
2 checks passed
@foxable
foxable deleted the feat/response-header-report branch October 19, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants