Projects

Cloudflare Doctor

Read-only Cloudflare scanner, v0: one TypeScript engine for a CLI and a hosted service on Workers, D1 and Workflows, with a resource graph, 47 deterministic rules, SARIF output and a React dashboard.

At a glance

Role
Sole developer
Status
v0: used on my own personal and commercial projects; not deployed

Stack

  • Cloudflare D1
  • Cloudflare Workers
  • Cloudflare Workflows
  • Hono
  • React
  • SARIF
  • TypeScript

Key outcomes

  • Rules in the registry47
  • Test files7
  • D1 migrations3

Jump to technical deep dive

Technical deep dive

Expand a section for architecture detail, trade-offs, and evidence. Written for technical hiring managers.

Overview

Cloudflare Doctor is a read-only scanner for Cloudflare accounts. It discovers resources, builds a dependency graph of how they connect, checks them against deterministic misconfiguration rules, and tracks each finding over time. One shared engine powers both a CLI and a hosted service with a dashboard.

Problem

Cloudflare estates across personal and commercial projects grow quickly, and configuration mistakes are easy to miss, such as the ones the rules look for: a queue without a dead-letter queue, a binding pointing at something that no longer exists, a public development URL left on. Checking every product by hand in the dashboard does not scale, and the tool doing the checking must never touch application data.

Solution

- Probed the token's permissions first, so each product is marked available, forbidden or unsupported and the scan runs with what it can see - Collected configuration metadata only, across Workers, storage, queues, workflows, DNS and zones, security settings and other products; secret values are recorded only as present - Built a resource graph of bindings, consumers, dead-letter queues and domains, including derived Durable Objects - Evaluated 47 deterministic misconfiguration rules, each finding carrying its evidence - Gave every finding a stable fingerprint so repeat scans resolve or reopen it instead of duplicating it - Shipped a CLI with JSON and SARIF output and a fail threshold for pipelines, plus a hosted API, scheduled scans every six hours and a React dashboard

How it works: a scan verifies the integration, runs each collector phase as a separate Workflow step, builds the graph, evaluates the rules, reconciles findings against previous scans and records coverage and timing telemetry.

Architecture
WhatWhy
Shared engine: Packages for the API client, collectors, graph, rules, scanner pipeline and persistence, used by both CLI and hosted serviceLong term the CLI connects to the hosted service with API keys, so users scan from the site or inside their own workflows
API client: Pagination, bounded concurrency, retry and typed errorsStays within Cloudflare API rate limits on large accounts
Hosted scans: Cloudflare Workflows, one step per collector phase, then graph, rules and completionFailed steps are easy to manage, and each step finishes before the next is created
Persistence: D1 for integrations, scans, resources, findings and suppressions; an in-memory implementation behind the same interfaceSame engine with or without a database
Token handling: AES-GCM encryption in the app, tied to the integration and account, decrypted inside each stepEnough protection for a single-user tool without over-engineering
Output: Terminal, JSON and SARIF; dashboard with findings, resources, graph and scan comparisonFits both people and automated pipelines
Challenges

Scanning with incomplete permissions

Problem

Tokens rarely grant every product, and one failing collector should not sink the scan.

Solution

Capability probing, per-collector error isolation, a partial success status and a coverage report.

Trade-offs

Known limitation: a failed collector can still let reconciliation mark that product's findings as resolved. Next step: only resolve findings for products the scan actually covered.

Long, multi-phase scans on serverless

Problem

A full account scan spans many API calls and phases.

Solution

Each phase is a Workflow step; state lives in D1 between steps and the token is decrypted inside each step rather than passed along. Failed steps are easy to manage and every step completes before the next is created.

Findings that stay stable over time

Problem

Re-running a scan should not create duplicate findings or lose history.

Solution

Fingerprints built from the rule, integration, resources and key evidence; reconciliation resolves or reopens findings and keeps first-seen dates.

Trade-offs

Ignored findings exist because the tool does not cover everything yet; proper support is still to be implemented.

Decisions

One engine for CLI and hosted service

Alternatives

Separate CLI and service codebases

Why this choice

Users should scan from the site or in their own pipelines. Rules and collectors behave identically everywhere; the CLI will later call the hosted service with API keys.

Trade-off

Persistence sits behind an interface with D1 and in-memory versions.

Cloudflare Workflows for hosted scans

Alternatives

Queues or a single Worker run

Why this choice

Scans have many phases that can fail independently. Failed steps are easy to manage; each step finishes before the next is created.

Trade-off

Each step reloads state from D1 and decrypts the token again.

Token encryption in the app

Alternatives

Cloudflare Secrets Store

Why this choice

Single-user v0. Avoid over-engineering for one user.

Trade-off

Key management is manual for now; moving to Secrets Store for key generation is planned.

Misconfiguration rules first

Why this choice

v0 scope. Deterministic checks with evidence are easy to trust and test.

Trade-off

Best-practice coverage for every product still needs research.

Evidence
  • Rules in the registry47(Counted in the rule registry source, 26 Nov 2026)
  • Test files7(Repository tree, 24 Nov 2026)
  • D1 migrations3(Repository tree, 24 Nov 2026)
  • Real useFound misconfigurations on my own accounts that I then fixed, for example queues without consumers and other queue and workflow issues(My own use)
Reflection

- Learned: running it on my own accounts caught real queue and workflow misconfigurations, such as queues without consumers, which is the best test of a tool like this - Known limitation: partial scans can wrongly resolve findings; scoping reconciliation to covered products is the next step - To build: proper support for accepting or ignoring findings, and research into best practices for every product so the rules cover them - Planned: move key generation to Cloudflare Secrets Store; connect the CLI to the hosted service with API keys - Open decision: release as open source or offer it as a small subscription