Skip to content

Say so at boot when a site UUID has no credential behind it - #158

Merged
patchstackdave merged 1 commit into
mainfrom
credential-visibility-at-boot
Aug 20, 2026
Merged

Say so at boot when a site UUID has no credential behind it#158
patchstackdave merged 1 commit into
mainfrom
credential-visibility-at-boot

Conversation

@patchstackdave

Copy link
Copy Markdown
Contributor

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 only PATCHSTACK_PULSE_AUTH / PATCHSTACK_API_KEY can 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

createProtection reports once at boot, via onError and console.warn, when siteUuid is 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:

  • warns, and names what to set
  • reports through onError as well, for hosts that capture logs structurally
  • does not warn when a credential resolves — without this, the suite would also pass for a warning hard-wired to siteUuid, firing on every healthy install and training operators to ignore it
  • does not warn in bundled-rules mode — a supported configuration, not a misconfiguration: no per-site lookup, so nothing is missing
  • still blocks and still allows, proving the diagnostic never became a refusal to boot

Mutation-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.

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>
@coderbuds

coderbuds Bot commented Aug 20, 2026

Copy link
Copy Markdown

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

See how your team is trending →

@patchstackdave

Copy link
Copy Markdown
Contributor Author

/review

@patchstackdave
patchstackdave merged commit 10b5259 into main Aug 20, 2026
6 checks passed
@patchstackdave
patchstackdave deleted the credential-visibility-at-boot branch August 20, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants