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
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Finds inline scripts in an HTML page (read from stdin): the ones a Content-Security-Policy with script-src 'self' blocks.
#
# An inline script is a <script> WITHOUT a src attribute (wherever the attribute stands in the tag) whose content is not
# empty. Not counted: <script src="..."> (also with type="module", crossorigin, defer, ... in any order), an empty
# <script></script>, and data blocks that are not executed (type="application/json", "application/ld+json",
# "importmap" and the like). Prints the opening tag of every inline script found; no output means none.
# Plain POSIX tools only (no grep -P), so it behaves the same on every runner.
inline_scripts() {
tr '\r\n' ' ' \
| grep -oiE '<script[^>]*>[[:space:]]*[^[:space:]<]' \
| grep -viE '<script[^>]*[[:space:]]src[[:space:]]*=' \
| grep -viE '<script[^>]*type[[:space:]]*=[[:space:]]*["'\'']?(application/(ld\+)?json|importmap|speculationrules)' \
|| true
}