From a9da249760b9ae431326fd581a0667f63ca921ff Mon Sep 17 00:00:00 2001 From: Lucio Chen Date: Tue, 9 Jun 2026 20:14:30 -0700 Subject: [PATCH] Remove unsafe-inline from script-src CSP Move every inline + {{end}} diff --git a/internal/server/templates/admin_bin.html b/internal/server/templates/admin_bin.html index c5a437e..ab28a2e 100644 --- a/internal/server/templates/admin_bin.html +++ b/internal/server/templates/admin_bin.html @@ -46,10 +46,10 @@
- - Edit - -
+ + Edit + +
@@ -73,91 +73,12 @@ Preview
Open ↗ - - + +
- + {{end}} diff --git a/internal/server/templates/admin_bin_edit.html b/internal/server/templates/admin_bin_edit.html index ca9cbda..12fd4a3 100644 --- a/internal/server/templates/admin_bin_edit.html +++ b/internal/server/templates/admin_bin_edit.html @@ -63,7 +63,7 @@
- @@ -90,15 +90,15 @@

Current token: {{.Token}} — URL: /bin/{{.Name}}/{{.Token}}

- - - - + + + + {{else}}

Token is currently disabled — paste is publicly accessible.

- - - + + + {{end}} - + {{end}} diff --git a/internal/server/templates/admin_edit.html b/internal/server/templates/admin_edit.html index 6c9ef97..cbc4be6 100644 --- a/internal/server/templates/admin_edit.html +++ b/internal/server/templates/admin_edit.html @@ -40,11 +40,7 @@
- + {{else}}
Link not found.
{{end}} diff --git a/internal/server/templates/admin_uploads.html b/internal/server/templates/admin_uploads.html index 61ce2a2..71ddf6a 100644 --- a/internal/server/templates/admin_uploads.html +++ b/internal/server/templates/admin_uploads.html @@ -22,7 +22,7 @@

{{len .Uploads}} file{{if ne (len .Uploads) 1}}s{{end}} stored locally.

- @@ -71,9 +71,9 @@ {{.ModTime.Format "2006-01-02 15:04"}}
- - {{if .CanResize}}{{end}} -
+ + {{if .CanResize}}{{end}} +
@@ -96,7 +96,7 @@
- +

Resize Image

@@ -104,76 +104,12 @@
- +
- + {{end}} diff --git a/internal/server/templates/base.html b/internal/server/templates/base.html index 70fd764..cad8933 100644 --- a/internal/server/templates/base.html +++ b/internal/server/templates/base.html @@ -88,9 +88,9 @@
-
+
- +

QR Code

QR Code @@ -98,23 +98,6 @@
- + {{end}} diff --git a/internal/server/templates/bin_token.html b/internal/server/templates/bin_token.html index eca9825..e02e0d5 100644 --- a/internal/server/templates/bin_token.html +++ b/internal/server/templates/bin_token.html @@ -22,13 +22,5 @@
- + {{end}} diff --git a/internal/server/templates/bin_view.html b/internal/server/templates/bin_view.html index 21fcf49..6871cf1 100644 --- a/internal/server/templates/bin_view.html +++ b/internal/server/templates/bin_view.html @@ -19,7 +19,7 @@
Raw - +
@@ -33,15 +33,7 @@ - + {{else}}

Paste not found

diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index 2a37d84..90c1805 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -23,7 +23,7 @@
{{.ShortURL}} - +
{{if .QRSVG}}
{{.QRSVG}}
@@ -52,20 +52,5 @@ - + {{end}} diff --git a/plan.md b/plan.md index 977a947..af97fec 100644 --- a/plan.md +++ b/plan.md @@ -1,8 +1,7 @@ # Hardening / Robustness Plan -> Progress: items 1–4 done (build/vet/tests green, ARMv5 cross-compile -> verified). Item 5 remains — large template refactor, best done as its own -> piece of work. +> Progress: all five items done. Item 5 verified in a live browser session +> (every page exercised, zero console errors / CSP violations). Follow-ups from the 2026-06-09 security review (fixes from that review already landed in `962f5d9`). Status legend: ☐ todo · ◐ in progress · ☑ done @@ -46,12 +45,16 @@ upload serving) have zero tests. Add `handlers_test.go` covering at least: - login: wrong password → 401, correct → session cookie + redirect - oversized-image rejection from item 1 -## 5. ☐ Drop `'unsafe-inline'` from `script-src` (CSP) +## 5. ☑ Drop `'unsafe-inline'` from `script-src` (CSP) -All template JS is inline, so the CSP doesn't actually block injected -scripts. Move inline blocks into embedded static files (the `upload.js` -pattern) and tighten `script-src` to `'self'`. Touches every template — -deliberately last, and large enough that it may warrant its own session. +Done: all inline `