Repository navigation
[ENG-4579] Make firewall log lines match what the guard did - #503
Merged
daniloradovic merged 1 commit intoNov 20, 2026
Merged
Conversation
Three fixes to the guard's detection reporting and its console line. A detect-only match on the `fetchGuard` path (the Next.js middleware, and the other templates that call it) was queued and left for a timer or a later request to send. On a host that freezes the function after the response, such as Vercel, neither runs, so the detection never reached the dashboard. `fetchGuard` now hands the queued report to the host's `waitUntil` when one is available, as `fetch` already does. Without one, delivery is unchanged. A match that did not block was logged as "Blocked by Patchstack WAF rule", because the engine's default message is written before the rule's mode is known. The message given to `onDetect`, and so the console line, now says "Matched by" when the mode is not block. Block responses are unchanged. Rules with no category, which is how the site's own rules arrive, were logged as `category=?`. They are now logged as `category=custom`. Amp-Thread-ID: https://ampcode.com/threads/T-2e659ca3-7bd0-4d70-b3d3-09638251060b Co-authored-by: Danilo Radovic <danilo@patchstack.com>
|
🎯 Elite quality (97%) — Targeted fix routes fetchGuard detect-only reports through waitUntil and corrects misleading log wording. 📦 Small 🤖 Written by Amp — going by its own attribution. Unknown whether a person read it; agents can report that with the 🟢 Low risk — 26 lines of code, and nothing that needs a person. ✅ Reviewed — approved by @mariojgt. |
Contributor
Author
|
/review |
mariojgt
approved these changes
Nov 20, 2026
daniloradovic
deleted the
danilo/eng-4579-firewall-log-entries-do-not-match-the
branch
November 20, 2026 08:38
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.
Closes ENG-4579
What changed
fetchGuard(used by the Next.js middleware and other fetch-style templates) hands a queued detection report to the host'swaitUntilwhen one exists, asfetchalready does. Without one, delivery is unchanged.onDetectand the console line. Block responses are unchanged.category=custominstead ofcategory=?.Why
On hosts that freeze the function after the response (Vercel), a detect-only report waited for a timer or a later request that never came, so detections went missing from the dashboard. Detect-only lines also claimed something was blocked.
Not done, on purpose
Duplicate entries when both the middleware and the route handler screen one request. On Vercel those run as separate invocations, so there is no unforgeable marker to share, and a client-settable header would let an attacker merge away their own detections. Left for a separate design.
How it was verified
waitUntil, posts the report, and logs DETECT /category=custom/ "Matched by". It fails onmain.npm run typecheck,npm run build,npm run test:bundled,npx vitest run(4751 passed, 7 skipped).