Skip to content

feat(cloudflare): add WAF rulesets, rate limiting, Zero Trust Access, R2, Workers, and Tunnels - #6740

Merged
waleedlatif1 merged 10 commits into
stagingfrom
feat/cloudflare-depth
Aug 16, 2026
Merged

feat(cloudflare): add WAF rulesets, rate limiting, Zero Trust Access, R2, Workers, and Tunnels#6740
waleedlatif1 merged 10 commits into
stagingfrom
feat/cloudflare-depth

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Cloudflare goes from 13 to 47 tools: WAF/rulesets, rate limiting, Access (Zero Trust), R2, Workers, and Tunnels
  • Fixed a shipped-tool defaulting regression: a newly added Access type subBlock defaulting 'self_hosted' was overwriting the pre-existing DNS Record Type default of 'A'. SubBlock defaults are seeded into block state keyed by subBlock id, so the last definition in file order silently wins. Four ids were affected — the colliding controls now carry their own ids (recordType, recordProxied, certificateStatus, appType, rateLimitAction) and are remapped back to their tool param names at the top of tools.config.params, before any coercion runs, so no alias id reaches a tool. Regression test added
  • Removed 25 any occurrences from the tool layer, which surfaced four real output-shape mismatches between transformResponse and the declared outputs

Deliberate omissions

  • Firewall/security events are not implemented. The REST endpoint was deprecated in 2020, and the GraphQL firewallEventsAdaptive dataset has no published field reference — implementing it would require live schema introspection rather than documented behavior
  • Enterprise complexity-based rate limiting (score_per_period, score_response_header_name) is left out

Type of Change

  • New feature
  • Bug fix

Testing

Tested manually. 9 subBlock-collision tests added and passing; docs, tool metadata, and integration catalog regenerated and verified in sync.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 16, 2026 1:55am

Request Review

@cursor

cursor Bot commented Aug 15, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Many new operations change live WAF, Access, and rate-limit behavior on production zones; mistaken params can remove protection or widen access immediately. Mapper/alias logic is security-sensitive but covered by new tests.

Overview
Expands the Cloudflare integration from 13 to 48 operations, with docs and catalog updates. New coverage includes WAF rulesets (custom/managed rules, overrides), Rulesets-based rate limiting, Cloudflare Access (apps, policies, groups, IdPs, service tokens), R2 buckets, Workers (scripts, routes, settings), and Tunnels (list/get/config). Integration copy now emphasizes WAF, Zero Trust, and edge infrastructure instead of DNS/cache only.

Fixes a subBlock default collision bug: block state is keyed by subBlock id, so reused ids (e.g. type, status, proxied) let later controls overwrite earlier defaults—Access self_hosted could replace DNS record type A. Colliding controls now use dedicated ids (recordType, certificateStatus, rateLimitAction, etc.) and SUBBLOCK_ALIASES remaps them to tool params before coercion; alias ids are cleared so they never leak as API params. Update flows for Access apps/policies and rate limits avoid seeded defaults on full-replace endpoints.

Adds cloudflare.test.ts with regression tests for defaults, aliases, read-vs-write id reuse, and advanced hidden controls that could serialize stale values across operations. Templates/skills for WAF rollout, rate limits, and Access review are included.

Reviewed by Cursor Bugbot for commit 81b5a61. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR expands the Cloudflare integration with WAF rulesets, rate limiting, Zero Trust Access, R2, Workers, and Tunnels while correcting conflicting subBlock defaults.

  • Adds and registers 34 Cloudflare operations with generated metadata, outputs, integration catalog entries, and documentation.
  • Introduces operation-specific subBlock aliases that are remapped to tool parameter names before execution.
  • Adds regression coverage for conflicting defaults, alias remapping, and Cloudflare block configuration invariants.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/cloudflare.ts Expands the Cloudflare block operation catalog and remaps uniquely identified controls before coercion to prevent conflicting seeded defaults.
apps/sim/tools/cloudflare/cloudflare.test.ts Adds regression tests covering alias remapping, conflicting defaults, incompatible dropdown definitions, and hidden-control applicability.
apps/sim/tools/cloudflare/utils.ts Provides shared request, response, and parsing utilities used by the expanded Cloudflare tool set.
apps/sim/tools/cloudflare/types.ts Defines typed Cloudflare API envelopes and resource shapes used to replace loose tool-layer types.
apps/sim/tools/cloudflare/index.ts Exports the expanded Cloudflare tool collection for registry integration.
apps/sim/tools/registry.ts Registers the newly added Cloudflare operations in the application tool catalog.
apps/docs/content/docs/en/integrations/cloudflare.mdx Documents the expanded Cloudflare operation set, inputs, outputs, permissions, and operational caveats.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  UI[Cloudflare block controls] --> State[Persisted subBlock state]
  State --> Params[tools.config.params]
  Params --> Alias[Operation-specific alias remapping]
  Alias --> Coerce[Parameter coercion]
  Coerce --> Tool[Selected Cloudflare tool]
  Tool --> API[Cloudflare API]
  API --> Transform[Response transformation]
  Transform --> Output[Workflow output]
Loading

Reviews (9): Last reviewed commit: "fix(cloudflare): stop the Access replace..." | Re-trigger Greptile

Comment thread apps/sim/blocks/blocks/cloudflare.ts Outdated
Comment thread apps/sim/blocks/blocks/cloudflare.ts Outdated
Comment thread apps/sim/tools/cloudflare/create_rate_limit_rule.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/blocks/blocks/cloudflare.ts
Comment thread apps/sim/blocks/blocks/cloudflare.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/blocks/blocks/cloudflare.ts
Comment thread apps/sim/blocks/blocks/cloudflare.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
waleedlatif1 force-pushed the feat/cloudflare-depth branch from 465909a to 226a444 Compare August 16, 2026 01:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 465909a. Configure here.

Comment thread apps/sim/blocks/blocks/cloudflare.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2553e8c. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
waleedlatif1 force-pushed the feat/cloudflare-depth branch from 2553e8c to a42e330 Compare August 16, 2026 01:35
Comment thread apps/sim/blocks/blocks/cloudflare.ts Outdated
Comment thread apps/sim/blocks/blocks/cloudflare.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 81b5a61. Configure here.

… R2, Workers, and Tunnels

Extends the Cloudflare integration past DNS/zones/cache with the security and
Zero Trust surface:

- Rulesets engine (zone-scoped): list rulesets, get a ruleset, read a phase
  entry point, and create/update/delete rules. WAF managed-rule overrides are
  surfaced through the http_request_firewall_managed entry point, since
  Cloudflare has no dedicated overrides endpoint.
- Rate limiting (zone-scoped) via the current Rulesets-based http_ratelimit
  phase, not the deprecated rate_limits endpoint.
- Cloudflare Access (account-scoped): applications, application policies,
  groups, identity providers, and service tokens.
- R2 buckets, Workers scripts/routes, and cloudflared Tunnels.

Destructive operations (delete application, delete policy, revoke service
token, delete rule, delete bucket) spell out their blast radius, and every
tool branches on the envelope's success flag rather than the HTTP status.

Security events are intentionally omitted: Cloudflare exposes them only
through the GraphQL firewallEventsAdaptive dataset, whose field list is not
documented outside schema introspection.
Validation pass over all 47 Cloudflare tools against developers.cloudflare.com.

- Two tool descriptions still escaped a quote as \'. That reaches the model
  verbatim and truncates the generated MDX cell — the get_zone_settings
  `value` output row was missing from the published docs entirely. Both are
  now template literals, and the row is back.
- list_rulesets ignored pagination. The endpoint pages by cursor via
  result_info.cursors.after (not page/per_page), so a zone with many rulesets
  silently truncated with no way to page. Expose per_page + cursor and return
  the next cursor.
- The managed-ruleset override description claimed action and enabled were
  the overridable properties. They are the ones the Rulesets engine documents
  at every level, but individual managed rulesets add more: an OWASP Core
  Ruleset rule override also takes score_threshold. Corrected in both the
  tool output description and the block's action-parameters wand prompt.
  (sensitivity_level is a DDoS override, not a WAF one — deliberately absent.)
- list_tunnels/get_tunnel dropped the documented `metadata` field.
- list_r2_buckets appended order=name whenever any filter was set. `order`
  only qualifies `direction`, and `name` is its sole documented value.
- Path-interpolated IDs are trimmed, so a pasted ID with trailing whitespace
  no longer 404s.
- Replaced every `any` in the integration with checked types: a shared
  CloudflareEnvelope plus per-resource raw payload interfaces, read through
  readCloudflareResponse. The mappers in utils.ts were the widest hole —
  typing them caught four real output-shape mismatches (identity provider
  read_only, service token enabled, DNS record meta/priority, certificate
  geo_restrictions) that `any` had been hiding.
- BlockMeta only described DNS and zone work. Added templates and skills for
  the WAF, rate limiting, and Zero Trust Access surfaces the block now has.

Confirmed against the docs and left unchanged: rulesets/rate limiting are
zone-scoped and Access/R2/Workers scripts/Tunnels are account-scoped while
Workers routes are zone-scoped; tunnels live under /accounts/{id}/cfd_tunnel;
the ratelimit object is a sibling of action/expression, not nested in
action_parameters; every rate limiting period and mitigation_timeout option
matches the documented set; R2 delete returns an empty result so echoing the
requested bucket name is correct; app-nested Access policy endpoints are
current, not deprecated; and every tool fails on a 200 carrying success:false.
…shared id

Subblock initial values are seeded into block state keyed by subblock id —
both stores/workflows/utils.ts and lib/workflows/defaults.ts assign
`subBlocks[subBlock.id]` in a plain forEach — so two controls sharing an id
leave one stored value and the last definition in file order wins. Four ids
were duplicated with differing defaults:

- `type` was defined four times. The Access "Application Type" control is
  last, so every new block seeded `type = 'self_hosted'` and the three DNS
  record controls inherited it — Create DNS Record sent a Zero Trust
  application type as its record type. The subblock added on this branch
  broke a default on tools that shipped long before it.
- `status` was defined three times. The empty tunnel filter is last, so
  List Certificates lost its `all` default.
- `proxied` was defined three times. An empty filter is last, so Create DNS
  Record lost its explicit `false`.
- `action` was defined twice. The rate limiting dropdown is last, so the
  ruleset-rule action input was seeded `block`, quietly making "block live
  traffic" the default for a WAF custom rule the user never configured.

Give the colliding controls their own ids and map them back to the tool
params per operation, ahead of the coercions that read them, so each
operation keeps its own default. The other 17 duplicated ids agree on their
value and are left shared.

Adds tests covering each separated default plus a sweep asserting no id
carries two different seeded values, so a future duplicate goes red.
… a phase ruleset

The Access policy include wand asked for a JSON object while the tool parses
the field with parseJsonArrayParam, so generated rules failed validation.
Switch it to json-array, whose prompt reinforcement omits the object braces.

Rate limiting and WAF custom rules could only be appended to an existing
ruleset, but a zone that has never had a rule in a phase has no entry point
ruleset and returns 404, leaving no way to add the first rule. Add
cloudflare_create_ruleset for the documented POST /zones/{id}/rulesets
bootstrap, seeded with optional initial rules.
…g into writes

Independent re-validation of all 48 tools against developers.cloudflare.com
turned up defects that the shipped tools would have hit on their happy path.

Delete DNS record reported every success as a failure. That endpoint is the
one Cloudflare v4 response with no envelope — its documented body is
`{"result":{"id":...}}` with no `success` — so `!data.success` was always
true. Branch on an explicit `=== false` instead.

The two replace-semantics PATCH endpoints could silently destroy live config.
Update rate limit rule defaulted a missing action to `block`, converting an
existing `log` or challenge rule into a hard block on real traffic; update
ruleset rule left action and expression optional and had no `ratelimit` or
`logging` passthrough, so updating a rate limiting rule stopped it rate
limiting. Both now require the fields the replacement needs, and the ruleset
rule carries the two nested objects through.

Access applications were unbuildable for most types: `domain` was required,
but it does not exist on the saas, app_launcher, warp, biso, dash_sso,
infrastructure, mcp, mcp_portal, or proxy_endpoint request variants. The
application type enum was also six values behind. Access group `is_default`
is an array of rule objects, not a boolean.

Purge cache merged every supplied target into one body, but the purge body is
a one-of over the five target kinds; it now names the conflict instead.

The remaining fixes are documentation drift: the priority field is MX and URI
only (an SRV record carries priority inside its content), the certificate
status filter documents only "all", the Worker tag filter takes tag:allowed
pairs, and the managed-rule override list conflated the DDoS-only
sensitivity_level with the WAF rule-level set.

Separately, controls that share a subBlock id share one stored value, and
`shouldSerializeSubBlock` short-circuits on `mode: 'advanced'` before it
evaluates `condition` — so a hidden list filter was reaching a write. A
`list_dns_records` content filter could overwrite a record's content, cache
tags could be written onto a DNS record, and the zone status enum could reach
the tunnel list, whose enum is disjoint. Filters that differ from the value
they collided with now carry their own id, remapped through one table before
any coercion. Sharings that mean the same thing everywhere are unchanged.

Aliases are cleared by explicit assignment rather than destructuring, because
the executor merges the mapper's output over the raw inputs and a merely
omitted key survives as its raw subBlock string. The tests assert on that
merged result, and three mechanical invariants now go red on a new collision:
no id spans a read filter and a written value, no dropdown id carries two
option sets, and no hidden advanced control feeds an operation that cannot
render it. That last one found the name filter reaching three list operations.
Cloudflare deprecated the field in favour of destinations, which the tools
already surface. The output stays — Cloudflare still returns it — but the
description now says which one to read.
create_dns_record now takes its record type from the recordType control,
whose dropdown has no empty option, so the operation can never reach this
guard with an empty type. Clear it unconditionally.
…trols

The list filters that were split off their write-side twin kept their old ids
in canvasPresentation, so seven clauses referenced a control that is no longer
visible for that operation — check:canvas-sentences catches exactly this, and
a broken clause fails silently on the card rather than throwing.
…ing update

Making action required on update_rate_limit_rule was only half the fix: the
Action dropdown still seeded block for the update operation too, so an update
that edited only the threshold kept sending block and converted a live log or
challenge rule into a hard block — exactly the harm the required flag was
meant to prevent. The update now has its own control with no seeded value, so
the action is something the caller states rather than inherits.

The certificate status filter also still offered Active and Pending, which
Cloudflare does not document for that endpoint; the only documented value is
all, and omitting it returns active packs.
…cision

Same class as the rate limiting action: both Access updates are full
replacements, and the shared controls seeded self_hosted and allow for the
update operations too. Editing only a policy's include rules would silently
convert a live deny, bypass, or non_identity policy to allow — widening who
gets in — and editing an application would rewrite what it IS.

Each update now has its own required control with no seeded value, so the
type and the decision are stated rather than inherited. Regression tests
cover both, and the canvas sentence follows the renamed decision control.
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.

1 participant