Say so at boot when a site UUID has no credential behind it - #158
Merged
Conversation
The credential is read from .patchstackrc.json, which needs a filesystem and a working directory. Not every runtime this guard targets has either: on a Worker or an edge function the file is absent and only PATCHSTACK_PULSE_AUTH / PATCHSTACK_API_KEY can carry it. Nothing about that shows up in traffic. The rules fetch simply goes out unauthenticated, and if it is ever refused the guard fails open onto its cached or bundled rules and keeps screening every request. An app running the rule set it installed with looks exactly like an app running the current one — no error, no behavioural difference, nothing to notice. So report it once at boot, through onError and a warning, naming the site and the variable that fixes it. A warning rather than a throw: a missing credential costs rule freshness, and refusing to boot over it would cost protection entirely, which is strictly worse. Tested for the diagnostic AND its absence — no warning when a credential resolves, and none in bundled-rules mode where there is no per-site lookup to authenticate. Without those controls the assertion would also pass for a warning hard-wired to siteUuid, which would fire on every healthy install. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Adds audible boot-time warning when a site UUID lacks credentials. 🎯 Quality: 100% Elite · 📦 Size: Medium 📈 This month: Your 105th PR — above team average · Averaging Excellent |
Contributor
Author
|
/review |
mariojgt
approved these changes
Aug 20, 2026
daniloradovic
approved these changes
Aug 20, 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.
ENG-3641
A guard configured with a site UUID but no resolvable credential currently boots in complete silence. This makes it audible.
Why it is invisible today
The credential is read from
.patchstackrc.json, which needs a filesystem and a working directory. Not every runtime this guard targets has either — on a Worker or an edge function the file is absent, and onlyPATCHSTACK_PULSE_AUTH/PATCHSTACK_API_KEYcan carry it.Nothing about that surfaces in traffic. The rules fetch goes out unauthenticated; if it is ever refused, the guard fails open onto its cached or bundled rules and carries on screening every request. An app running the rule set it installed with looks exactly like an app running the current one — no error, no behavioural difference, nothing to notice. The failure mode is a site that silently stops learning about new vulnerabilities while reporting perfect health.
The change
createProtectionreports once at boot, viaonErrorandconsole.warn, whensiteUuidis set and no credential resolves. The message names the site and the variable that fixes it — a diagnostic that states a symptom without a remedy leaves an operator on a filesystem-less runtime with no next step, which is exactly where this happens.A warning, not a throw. A missing credential costs rule freshness; refusing to boot over it would cost protection entirely.
Tests
tests/protect/credential-visibility.test.ts— five cases, and two of them are controls:onErroras well, for hosts that capture logs structurallysiteUuid, firing on every healthy install and training operators to ignore itMutation-checked: dropping the credential check fails only the control; removing the diagnostic fails only the two positive cases; dropping the remedy from the message fails only the assertion about the remedy.
Full suite green (1254 passed, 6 skipped), typecheck and template typecheck clean.