Smoke: controle op inline scripts zonder grep -P, JSON-blokken en importmaps tellen niet; test erbij

De controle staat in scripts/lib-inline-script.sh (alleen POSIX-tools), met een test (scripts/test-inline-script-check.sh) en een lokale proef van smoke-site.sh tegen een admin-pagina met en zonder inline script. De melding noemt nu wat er gevonden is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 22:41:57 +01:00
co-authored by Claude Sonnet 5.5
parent 28b1c6d013
commit 9f07934f9e
3 changed files with 62 additions and 1 deletions
+6 -1
View File
@@ -10,6 +10,8 @@
# master CMS only; this script is the check that the deployed composition of a site is the one that was intended.
# A failing check makes the CI run fail.
set -u
# shellcheck source=lib-inline-script.sh
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib-inline-script.sh"
base="$(printf '%s' "${1:?usage: smoke-site.sh <url-on-the-host> <profile>}" | sed -E 's#^(https?://[^/]+).*#\1#')"
profile="${2:?profile (sls-test | asf-test) is required}"
@@ -58,9 +60,12 @@ expect_status /api/v1/hero/all 401 "the hero management read is protected"
expect_status /media/hero/0123456789abcdef/wide-960.webp 404 "media that is not stored is a plain 404"
# The admin page must have no inline script: the host only allows scripts from its own origin (script-src 'self').
# The check lives in lib-inline-script.sh (and is tested by test-inline-script-check.sh); it prints what it found.
admin_html="$(curl_get "$base/admin/" || true)"
if printf '%s' "$admin_html" | grep -q 'id="root"'; then
if printf '%s' "$admin_html" | grep -qiP '<script(?![^>]*src=)[^>]*>'; then fail "the admin page has an inline script (blocked by the Content-Security-Policy)"; else pass "the admin page has no inline script"; fi
inline_found="$(printf '%s' "$admin_html" | inline_scripts)"
if [ -n "$inline_found" ]; then fail "the admin page has an inline script (blocked by the Content-Security-Policy): $(printf '%s' "$inline_found" | head -3 | tr '
' ' ')"; else pass "the admin page has no inline script"; fi
expect_status /admin/theme-init.js 200 "the theme script is a file of its own"
fi