ci: rust job through the builder image, worker test stage and runtime start, nightly advisories, manual digest-tagged release-images workflow; CSP proof script

This commit is contained in:
bchanot committed 2026-10-13 00:01:26 +02:00
1 parent 3970cdca52
commit 4833fd29ef
7 files changed
+131 -1

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { chromium } from 'playwright-core'
const exe = process.env.CHROME
const browser = await chromium.launch({ executablePath: exe, headless: true })
for (const [name, port] of [['without wasm-unsafe-eval', 8091], ['with wasm-unsafe-eval', 8092]]) {
const page = await browser.newPage()
const logs = []
page.on('console', (m) => logs.push(`${m.type()}: ${m.text()}`))
page.on('pageerror', (e) => logs.push(`pageerror: ${e.message}`))
const resp = await page.goto(`http://127.0.0.1:${port}/`)
const csp = resp.headers()['content-security-policy']
await page.waitForFunction(() => document.title !== 'pending', null, { timeout: 10000 }).catch(() => {})
const wasmResp = await page.request.get(`http://127.0.0.1:${port}/pkg/faunosteo_wasm_bg.wasm`)
console.log(`== ${name}: title="${await page.title()}" csp-has-wasm-unsafe-eval=${csp.includes('wasm-unsafe-eval')} wasm-content-type=${wasmResp.headers()['content-type']}`)
for (const l of logs) console.log(' ' + l.slice(0, 220))
await page.close()
}
await browser.close()
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# R0 proof (D-R13): the browser module instantiates under the production CSP only with
# 'wasm-unsafe-eval'. Serves packages/core-wasm/pkg through the production nginx image with
# the DEPLOY.md header (as is, then with the keyword) and loads the page in headless Chromium.
#
# pnpm wasm:build
# CHROME=/path/to/chrome bash docker/csp-proof/run.sh # needs playwright-core on NODE_PATH
#
# Recorded result (2026-10-12, Chrome for Testing 156, nginx:1.31-alpine): docs/development/RUST.md §5.
set -euo pipefail
cd "$(dirname "$0")/../.."
work="$(mktemp -d)"
mkdir -p "$work/site"
cp -r packages/core-wasm/pkg "$work/site/"
cp docker/csp-proof/site/index.html docker/csp-proof/site/main.js "$work/site/"
prod_csp="$(grep -m1 '^add_header Content-Security-Policy' DEPLOY.md | sed -E 's/^add_header Content-Security-Policy "(.*)" always;$/\1/')"
wasm_csp="${prod_csp/script-src \'self\'/script-src \'self\' \'wasm-unsafe-eval\'}"
for variant in without with; do
if [ "$variant" = without ]; then csp="$prod_csp"; else csp="$wasm_csp"; fi
sed "s/\${PORT}/8080/; s|^ # SPA fallback| add_header Content-Security-Policy \"$csp\" always;\n # SPA fallback|" docker/nginx.conf > "$work/csp-$variant.conf"
done
cleanup() { docker rm -f faunosteo_csp_without faunosteo_csp_with >/dev/null 2>&1 || true; }
trap cleanup EXIT
cleanup
docker run -d --rm --name faunosteo_csp_without -p 127.0.0.1:8091:8080 -v "$work/site:/usr/share/nginx/html:ro" -v "$work/csp-without.conf:/etc/nginx/conf.d/default.conf:ro" nginx:1.31-alpine >/dev/null
docker run -d --rm --name faunosteo_csp_with -p 127.0.0.1:8092:8080 -v "$work/site:/usr/share/nginx/html:ro" -v "$work/csp-with.conf:/etc/nginx/conf.d/default.conf:ro" nginx:1.31-alpine >/dev/null
sleep 1.5
node docker/csp-proof/run.mjs
+2
View File
@@ -0,0 +1,2 @@
<!doctype html><meta charset="utf-8"><title>pending</title>
<script type="module" src="./main.js"></script>
+2
View File
@@ -0,0 +1,2 @@
import init, { core_version } from './pkg/faunosteo_wasm.js'
try { await init(); document.title = 'OK ' + core_version() } catch (e) { document.title = 'FAIL ' + (e && e.message) }