Skip to content

fix(docs): prevent JSON-LD script breakout - #78670

Merged
pelikhan merged 1 commit into
mainfrom
pelikhan/jubilant-engine
Nov 17, 2026
Merged

pelikhan merged 1 commit into
mainfrom
pelikhan/jubilant-engine

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

Summary

JSON serialization alone does not make structured data safe inside an HTML script element. Published page metadata could terminate the JSON-LD blocks emitted by the docs head or inherited from the blog plugin.

Escape literal < characters after serialization for both paths, preserving the original values when JSON is parsed. Ordinary JavaScript head entries are unchanged.

Add production-build regressions covering docs and blog titles/descriptions independently, nested blog author/tag values, and homepage structured data.

Validation

  • npm --prefix docs run test:jsonld: 6 passed using the real Astro/Starlight build and locked blog plugin.
  • make agent-report-progress: passed; impacted Go tests skipped because no Go files changed.
  • make agent-report-progress-no-test: passed on the final candidate.
  • Mitigation security review: PASS.

Limitation

Threat-detector effectiveness remains unverified. The separate local detector probe was blocked by its credential/network isolation review and was not executed. No GitHub Actions workflow was dispatched.

Protect custom and inherited blog structured data from script termination while preserving JSON values. Add production-build regressions for docs and blog metadata.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review November 17, 2026 07:37
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 07:37
@pelikhan
pelikhan merged commit c4e7a8c into main Nov 17, 2026
25 checks passed
@pelikhan
pelikhan deleted the pelikhan/jubilant-engine branch November 17, 2026 07:37
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Playwright discovers the JSON-LD Node test, causing its hooks and Astro build to run outside Playwright’s lifecycle and reporting.

1 open issue
What changed in this PR

Hardens the docs site's JSON-LD against script-element breakout by escaping literal < characters after serialization without changing parsed values.

Changes:

  • Protects structured data generated by the custom head and inherited from the blog plugin.
  • Leaves ordinary JavaScript head entries unchanged.
  • Adds production-build regression tests for hostile metadata, nested blog values, and homepage structured data.
File Description
docs/​tests/​jsonld-security.test.mjs Adds escaping and production-build security regressions.
docs/​src/​lib/​json-ld.js Provides the serialized JSON-LD escaping helper.
docs/​src/​components/​CustomHead.astro Applies escaping to custom and inherited JSON-LD blocks.
docs/​package.json Adds the dedicated test:jsonld command.

Review effort: Max (adaptive)

import assert from "node:assert/strict";
import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { after, before, test } from "node:test";
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.1

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