File tree Expand file tree Collapse file tree 4 files changed +17
-19
lines changed
Expand file tree Collapse file tree 4 files changed +17
-19
lines changed Original file line number Diff line number Diff line change 1515 cache : pnpm
1616 - run : pnpm install --frozen-lockfile
1717 - name : Verify CSP inline script hash
18- run : |
19- SCRIPT=$(sed -n 's/.*<script>\(.*\)<\/script>.*/\1/p' index.html)
20- HASH=$(printf '%s' "$SCRIPT" | openssl dgst -sha256 -binary | base64)
21- if ! grep -q "sha256-$HASH" public/_headers; then
22- echo "::error::CSP hash mismatch! Inline script hash 'sha256-$HASH' not found in public/_headers"
23- echo "Update the sha256 hash in public/_headers to match the inline script in index.html"
24- exit 1
25- fi
26- echo "CSP hash verified: sha256-$HASH"
18+ run : bash scripts/verify-csp-hash.sh
2719 - run : pnpm run typecheck
2820 - run : pnpm test
2921 - name : Install Playwright browsers
Original file line number Diff line number Diff line change 1919 - run : pnpm run typecheck
2020 - run : pnpm test
2121 - name : Verify CSP inline script hash
22- run : |
23- SCRIPT=$(sed -n 's/.*<script>\(.*\)<\/script>.*/\1/p' index.html)
24- HASH=$(printf '%s' "$SCRIPT" | openssl dgst -sha256 -binary | base64)
25- if ! grep -q "sha256-$HASH" public/_headers; then
26- echo "::error::CSP hash mismatch! Inline script hash 'sha256-$HASH' not found in public/_headers"
27- echo "Update the sha256 hash in public/_headers to match the inline script in index.html"
28- exit 1
29- fi
30- echo "CSP hash verified: sha256-$HASH"
22+ run : bash scripts/verify-csp-hash.sh
3123 - name : WAF smoke tests
3224 run : pnpm test:waf
3325 - run : pnpm run build
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ priority = 0
4444id = " csp-hash"
4545name = " CSP hash verification"
4646language = " system"
47- entry = " bash -c 'SCRIPT=$(sed -n \" s/.*<script> \\ (.* \\ )< \\ /script>.*/ \\ 1/p \" index.html) && HASH=$(printf \" %s \" \" $SCRIPT \" | openssl dgst -sha256 -binary | base64) && grep -q \" sha256-$HASH \" public/_headers && echo \" CSP hash OK: sha256-$HASH \" || { echo \" CSP hash mismatch! sha256-$HASH not in public/_headers \" ; exit 1; }' "
47+ entry = " bash scripts/verify-csp- hash.sh "
4848pass_filenames = false
4949always_run = true
5050priority = 0
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ SCRIPT=$( sed -n ' s/.*<script>\(.*\)<\/script>.*/\1/p' index.html)
5+ HASH=$( printf ' %s' " $SCRIPT " | openssl dgst -sha256 -binary | base64)
6+
7+ if ! grep -q " sha256-$HASH " public/_headers; then
8+ echo " CSP hash mismatch! Inline script hash 'sha256-$HASH ' not found in public/_headers"
9+ echo " Update the sha256 hash in public/_headers to match the inline script in index.html"
10+ [[ -n " ${GITHUB_ACTIONS:- } " ]] && echo " ::error::CSP hash mismatch! sha256-$HASH "
11+ exit 1
12+ fi
13+
14+ echo " CSP hash verified: sha256-$HASH "
You can’t perform that action at this time.
0 commit comments