feat(protect): generic block message + branded HTML "Access Denied" page#78
Merged
Conversation
Two client-facing changes to request blocks: - De-narrativize the block text. The client body no longer says "Blocked by Patchstack WAF rule: <title>" — it's a generic "This request has been blocked by Patchstack." with no WAF wording and no rule title. The opaque rule id is kept as a machine field (server-fn receipts / support reference), and the full reason still goes to the server log via onDetect. - Serve a branded full-page "Access Denied" view (ported from the Patchstack WordPress plugin's sample.php → src/protect/block-page.js, self-contained inline CSS + base64 SVGs) when a BLOCKED request is a top-level document navigation (Sec-Fetch-Dest: document, or Accept: text/html). XHR/fetch clients still get masked JSON. The URL is HTML-escaped (no reflected XSS); the page shows the opaque rule id as a reference code, no rule detail. Wired across the fetch/route-WAF, node, and express block paths. +4 tests (HTML vs JSON routing, generic message, XSS escaping). 427 tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Branded HTML block page integrates well with robust JSON fallback. 🎯 Quality: 100% Elite · 📦 Size: Medium 📈 This month: Your 30th PR — above team average · Averaging Excellent |
Contributor
Author
|
/review |
devlob
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two client-facing changes to how a blocked request looks — less "WAF narrative", more like the Patchstack block view.
1. Generic block message (no WAF narrative)
The client body previously exposed
"Blocked by Patchstack WAF rule: <title>"+ the rule title. Now it's a generic "This request has been blocked by Patchstack." — no WAF wording, no rule title. The opaque rule id is kept as a machine field (server-fn receipts / support reference) and the full reason still goes to the server log viaonDetect.2. Branded HTML "Access Denied" page for navigations
When a blocked request is a top-level document navigation (
Sec-Fetch-Dest: document, or falling back toAccept: text/html), the guard now serves a branded full-page view — ported from the Patchstack WordPress plugin'ssample.phpintosrc/protect/block-page.js(self-contained: inline CSS + base64 SVGs, the "secured by Patchstack" footer). XHR/fetch clients still get masked JSON.Tests
+4 (
tests/protect/block-response.test.ts): HTML-vs-JSON routing by request type, generic message, opaque-id retention, URL escaping. 427 pass, typecheck + build clean.🤖 Generated with Claude Code