Skip to content

fix: drop style-src 'unsafe-inline' from the CSP - #22

Merged
wonmors merged 1 commit into
mainfrom
fix/csp-no-inline-styles
Nov 14, 2026
Merged

wonmors merged 1 commit into
mainfrom
fix/csp-no-inline-styles

Conversation

@xnosir

@xnosir xnosir commented Nov 14, 2026

Copy link
Copy Markdown
Member

Overview

Issue Closes #7
Scope 3 language pages (5 style attributes each), sanad-core.js step markup, sanad.css, deploy/Caddyfile, tools/check-site.mjs, docs
Deploy new CSP ships with the site container on merge

Problem

The CSP allowed style-src 'unsafe-inline' for a few style attributes (residual risk in docs/ASSURANCE.md). The demo also built step icons with style="position:absolute" in sanad-core.js.

Change

  • Page styles moved to classes (.src--meta, .tg-copy h2, .tg-copy h2 + .lead, .traveller, .traveller__card); step icon to .steps .st .i-x.
  • CSP: style-src 'self' 'sha256-y8K5...' (the favicon <style>, dark-mode colours).
  • check-site.mjs fails on a style attribute in pages or script-built markup, a <style> in pages, and an SVG <style> whose hash is not in the CSP.

Proof

Check Result
Computed styles before (old CSP) vs after (new CSP), /, /en/, /ru/ identical: #meta 0 18 16, #h-tg 58.88px/14px, lead 20px, card fill rgb(248,243,228)
Console under new CSP 0 errors (5 per page before the sanad-core.js fix)
npm test (43 unit + 29 e2e + coverage gate) pass
npm run lint 0 warnings
check-site negative test (old sanad-core.js) fails as expected

The five inline styles of each language page and the one in the demo step markup (sanad-core.js) move into sanad.css. The favicon keeps its <style>, allowed by its sha256 hash. tools/check-site.mjs now fails on a style attribute in a page or in script-built markup, a <style> in a page, and an SVG <style> whose hash is missing from the CSP.

Closes #7

Signed-off-by: xnosir <283333996+xnosir@users.noreply.github.com>
@xnosir
xnosir requested a review from a team as a code owner November 14, 2026 15:33
@wonmors
wonmors merged commit 3843e91 into main Nov 14, 2026
5 checks passed
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.

1 participant