feat(v3.16.0): security headers + Pages-demo retire + audit doc#84
Merged
Conversation
Adds CSP (enforcing, with SHA-256 hash for the single inline FOUC script), HSTS (max-age=31536000; includeSubDomains, no preload), Permissions-Policy denying 9 unused features incl. interest-cohort. Drops X-XSS-Protection (deprecated; Chrome removed support, Firefox never had it). CSP_DISABLE env var skips the CSP header for operators whose edge proxy emits its own. Regression tests lock the FOUC script hash against base.html and assert exactly one inline JavaScript across templates (JSON-LD excluded).
…e notes 12 deferred items filed to docs/audit-2026-05-frontend.md as a tracked index; each gets a GitHub issue (audit-finding label) post-merge. CHANGELOG v3.16.0 entry consolidates security headers + Live install README + audit-doc additions.
Collaborator
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max-age=31536000; includeSubDomains, no preload), Permissions-Policy (9-feature deny incl. FLoC opt-out), and aCSP_DISABLEenv var for operators behind edge proxies. Drops deprecatedX-XSS-Protection.docs/audit-2026-05-frontend.mdcatalogs 11 deferred frontend findings for v3.17.0+ scoping; each gets a GitHub issue with theaudit-findinglabel post-merge.Changes
internal/middleware/middleware.go—Security()accepts*config.Configto readSecurity.CSPDisable. Hash + policy constants documented inline.internal/config/config.go—SecurityConfig.CSPDisableloaded viagetEnvBool("CSP_DISABLE", false).internal/middleware/middleware_test.go—TestSecurityupdated to assert new headers + X-XSS-Protection absent.TestSecurity_FOUCScriptHashMatchesreadsweb.Assetsand asserts the hardcoded hash matchesbase.html's inline script content.TestSecurity_ExactlyOneInlineJavaScriptwalks templates and asserts no new inline<script>slips in without a hash (JSON-LD excluded — non-JS MIME).TestSecurity_CSPDisableSkipsCSPHeadercovers the toggle..env.example,docs/configuration.mddocumentCSP_DISABLEand the full security-header set.README.md,docs/audit-2026-05-frontend.md,CHANGELOG.mdcarry the demo-retire pointer + audit index + release notes.Test plan
make lint(postgolangci-lint cache clean) — 0 issuesmake test-race— greencurl -sI http://localhost:3000/— emits CSP/HSTS/Permissions-Policy/X-Content-Type-Options/X-Frame-Options/Referrer-Policy; X-XSS-Protection absentCSP_DISABLE=true ./build/markgo serve— CSP absent, other 5 headers present/,/writing,/writing/<slug>,/about,/p,/search,/compose— no CSP violationsOperator actions (post-merge, manual)
gh api repos/1mb-dev/markgo/pages --method DELETE(or disable Pages in repo settings) — retires the stale demogh api repos/1mb-dev/markgo --method PATCH -f homepage=https://log.1mb.dev— keeps the sidebar link valid after Pages disableaudit-findingissues fromdocs/audit-2026-05-frontend.mdand backfill theIssuecolumn