You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 040c120
Browse filesBrowse the repository at this point in the historyBrowse files
fix(protect): make the rule counts add up and say where the rules came from
- the runtime check's split includes outgoing rules, so it adds up to the two totals
- rules are 'from Patchstack' only when fetched; otherwise 'from its bundled rules file'
- the guard's own rules count is 'local', which also covers rules the host configures
- setup and the summary say 'protection rules from Patchstack' instead of 'available'
- setup does not mention the guard for an app with no server
- one rule is 'rule', not 'rules'
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ That's it. `setup` adds `@patchstack/connect` to the project when it is missing
147
147
148
148
If the server is already running, let the framework reload and check what it actually loaded: `patchstack-connect protect --check --runtime-url https://your-preview.example/api/contact` (loopback HTTP also works). You can supply the same `--runtime-url` to `setup`. This sends one signed, read-only OPTIONS challenge to that explicit URL, without sending the API key or following redirects. The response proves that a guard on that route loaded the current map, and reports its rule-readiness state and active rule counts. It does not prove other routes are covered or that an exploit is blocked. Both CLI and server need the site's server-side credential; `{ activationCheck: false }` disables the responder. If the guard cannot answer or carries an old map, restart/rebuild/deploy and check again. Setup never starts, builds or deploys your app.
149
149
150
-
Scaffolded guards refresh rules on a timer and on requests: once the rules are older than the refresh interval a request waits for the fetch, and every 30 seconds before that a serving guard re-checks in the background without holding any request, so a host that freezes between requests, or runs many copies of the app, picks up a rule change. Request-triggered refresh waits at most 2500ms by default, shares concurrent work, backs off after failures, and keeps last-known-good policy when offline. It never scans source or reports a manifest in the request path. A request with the header `x-patchstack-sync` runs that refresh straight away, at most once per 15 seconds; Patchstack sends one to the live site after its rules change. Hand-wired guards can configure `requestRefreshMs` (defaults to `refreshMs`, or zero when polling is disabled) and `requestRefreshTimeoutMs` (50–3000ms), or set the former to zero to opt out. `protection.synchronization` exposes the loaded identity, last successful lookup time, source health, readiness, rule counts (split into rules from Patchstack and rules built into the guard) and scoped-rule blocking counts without a network call. Rule refresh does not change the loaded map identity.
150
+
Scaffolded guards refresh rules on a timer and on requests: once the rules are older than the refresh interval a request waits for the fetch, and every 30 seconds before that a serving guard re-checks in the background without holding any request, so a host that freezes between requests, or runs many copies of the app, picks up a rule change. Request-triggered refresh waits at most 2500ms by default, shares concurrent work, backs off after failures, and keeps last-known-good policy when offline. It never scans source or reports a manifest in the request path. A request with the header `x-patchstack-sync` runs that refresh straight away, at most once per 15 seconds; Patchstack sends one to the live site after its rules change. Hand-wired guards can configure `requestRefreshMs` (defaults to `refreshMs`, or zero when polling is disabled) and `requestRefreshTimeoutMs` (50–3000ms), or set the former to zero to opt out. `protection.synchronization` exposes the loaded identity, last successful lookup time, source health, readiness, rule counts (`delivered` from Patchstack or the bundled rules file, `local` from the guard's own response and outgoing rules; `request`, `response` and `egress` count both) and scoped-rule blocking counts without a network call. Rule refresh does not change the loaded map identity.
151
151
152
152
The authenticated rules response may include `X-Patchstack-Map-Rules: pending | ready` alongside `X-Patchstack-Build-Match` and `X-Patchstack-Build-ID`, including on a `304`. Readiness applies only when the response confirms the exact map identity requested. An absent or unrecognized readiness value means **unknown**, not ready. The ETag identifies the delivered policy, not map-generation completion. Broad and hardening rules remain usable while map-specific rules are pending.
if(!status||status.siteUuid!==config.siteUuid)return{ok:false,message:'The selected URL did not prove activation for this site. Check the server credential, guard integration and deployed package version.'};
37
37
if(!expectedBuildId||status.buildId!==expectedBuildId)return{ok:false,message:'The guard answered, but its loaded map is absent or different. Let the framework reload, or restart/rebuild/deploy, then check again.'};
Copy file name to clipboardExpand all lines: src/cli.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1674,7 +1674,7 @@ async function runSetup(args: ParsedArgs): Promise<number> {
1674
1674
if(synced.rules.ok){
1675
1675
// Rules are enforced by protection in a server; an app without one has nothing to apply them.
1676
1676
if(!noServer)report.rules=synced.rules.count;
1677
-
report.done.push(`Live rule lookup succeeded (${synced.rules.count} rulesfrom Patchstack, on top of the guard's built-in rules; not proof of runtime enforcement)`);
1677
+
report.done.push(`Live rule lookup succeeded (${synced.rules.count}${synced.rules.count===1 ? 'rule' : 'rules'}from Patchstack${noServer ? '' : ", on top of the guard's own"}; not proof of runtime enforcement)`);
1678
1678
if(!noServer){
1679
1679
if(synced.rules.mapRules==='ready'){
1680
1680
report.done.push(`Rules for this map are ready${synced.rules.count===0 ? ' (no applicable rules)' : ''}`);
0 commit comments