pi-cloudflare 0.6.10 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cloudflare",
3
- "version": "0.6.10",
3
+ "version": "0.7.0",
4
4
  "description": "Cloudflare Agent Plugin and native Pi extension providing official skills and cf_-prefixed MCP tools.",
5
5
  "keywords": [
6
6
  "agent-plugin",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "pi-cloudflare",
4
- "version": "0.6.10",
4
+ "version": "0.7.0",
5
5
  "description": "Cloudflare skills and cf_-prefixed MCP tools, with a native Pi adapter and an Agent Plugins 1.0 portable runtime.",
6
6
  "author": {
7
7
  "name": "0xPlayerOne",
@@ -103,6 +103,17 @@ Then check the ruleset phases and add what is missing:
103
103
  - **`http_request_cache_settings`** — only with a measured reason; see
104
104
  [Safety rules](#safety-rules-do-not-blanket-change).
105
105
 
106
+ And remove what hurts performance. Hardening is not only additive:
107
+
108
+ - **`enable_js` (JavaScript Detections)** — injects
109
+ `/cdn-cgi/challenge-platform/scripts/jsd/main.js` into every HTML response and
110
+ trips Lighthouse Best Practices "Avoid deprecated APIs", costing roughly 40
111
+ Best-Practices points on a fast site. Turn it off; it protects nothing that
112
+ `ai_bots_protection: "block"` does not cover without injecting anything.
113
+ - **`fight_mode` (Bot Fight Mode)** — a genuine tradeoff rather than a free win.
114
+ It adds edge protection but rides on the same injected detection script. Report
115
+ the cost and let the user choose.
116
+
106
117
  ### 3. Per zone: DNSSEC
107
118
 
108
119
  Read `GET /zones/:id/dnssec`. If `disabled`, it is safe to stage: enabling is
@@ -66,14 +66,43 @@ Check that field before attempting a write; the PATCH will not tell you.
66
66
  The AI-bot and fight-mode fields live here, not under `/settings`. Use `PUT` —
67
67
  `PATCH` answers `405 10405`.
68
68
 
69
+ Send **only the fields being changed**. Echoing the whole object back fails with
70
+ `400 Bad Request`, because the write rejects computed and read-only fields
71
+ (`is_robots_txt_managed`, `using_latest_model`, and friends). Every other
72
+ setting is preserved on its own, so a partial body is correct rather than risky.
73
+
69
74
  ```jsonc
70
- // read first, then write back the merged object
75
+ // read first to see what is on
71
76
  GET /zones/:zone_id/bot_management
72
77
 
73
78
  PUT /zones/:zone_id/bot_management
74
79
  { "ai_bots_protection": "block" } // disabled | only_on_ad_pages | block
75
80
  ```
76
81
 
82
+ ### JavaScript Detections and Bot Fight Mode inject a script
83
+
84
+ Two fields on the same object add JavaScript to **every HTML response**:
85
+
86
+ | Field | Dashboard toggle | Effect |
87
+ | --- | --- | --- |
88
+ | `enable_js` | Security → Bots → JavaScript Detections | Injects `/cdn-cgi/challenge-platform/scripts/jsd/main.js` |
89
+ | `fight_mode` | Security → Bots → Bot Fight Mode | Adds edge protection; also drives the injected detection script |
90
+
91
+ The injected script trips Lighthouse Best Practices **"Avoid deprecated APIs"**
92
+ and costs roughly 40 Best-Practices points on a fast site, so treat `enable_js:
93
+ true` as a performance finding rather than a security win. Turning both off is a
94
+ tradeoff, not a free fix — it also removes edge bot protection, so say so in the
95
+ report.
96
+
97
+ ```jsonc
98
+ PUT /zones/:zone_id/bot_management
99
+ { "enable_js": false, "fight_mode": false }
100
+ ```
101
+
102
+ `ai_bots_protection: "block"` is the compromise: it blocks AI scrapers at the
103
+ edge, injects no script, and costs nothing. Prefer it when the user wants bot
104
+ protection without the performance hit.
105
+
77
106
  ## Free managed WAF ruleset
78
107
 
79
108
  The managed ruleset object **already exists** on every zone but is not applied —
@@ -207,13 +207,31 @@ async function auditZone(zone) {
207
207
  }
208
208
 
209
209
  // Bot management (AI bots / fight mode live here, not under /settings).
210
+ // enable_js injects a detection script into every HTML response, so it is a
211
+ // performance finding rather than a security gap. fight_mode is a genuine
212
+ // tradeoff and is reported, not flagged.
210
213
  const bot = await get(`/zones/${zone.id}/bot_management`)
211
214
  if (bot.result) {
212
- if (bot.result.ai_bots_protection && bot.result.ai_bots_protection !== 'block') {
213
- add(zone.name, 'info', 'ai_bots_protection', `currently ${bot.result.ai_bots_protection}`, 'consider "block" (PUT, not PATCH)')
215
+ if (bot.result.enable_js === true) {
216
+ add(
217
+ zone.name,
218
+ 'high',
219
+ 'javascript detections',
220
+ 'injects /cdn-cgi/challenge-platform/scripts/jsd/main.js into every HTML response',
221
+ 'turn off (PUT bot_management {enable_js:false}) — it trips Lighthouse Best Practices "deprecated API"'
222
+ )
214
223
  }
215
- if (bot.result.fight_mode === false) {
216
- add(zone.name, 'info', 'bot fight mode', 'disabled', 'consider enabling')
224
+ if (bot.result.fight_mode === true) {
225
+ add(
226
+ zone.name,
227
+ 'info',
228
+ 'bot fight mode',
229
+ 'on — a real tradeoff, not a free win',
230
+ 'adds edge protection but costs roughly 40 Lighthouse Best-Practices points via the injected detection script'
231
+ )
232
+ }
233
+ if (bot.result.ai_bots_protection && bot.result.ai_bots_protection !== 'block') {
234
+ add(zone.name, 'info', 'ai_bots_protection', `currently ${bot.result.ai_bots_protection}`, 'consider "block" — enforced at the edge, injects no script')
217
235
  }
218
236
  }
219
237