> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/c/cloudflare-waf.md).

# Cloudflare WAF

Cloudflare WAF protects web applications at the Cloudflare edge. OctoXLabs uses the Cloudflare API to add zones with their WAF packages and rules to the domain inventory.

## Use cases

* List the zones, WAF packages and rules that Cloudflare reports.

```
Adapters = cloudflare-waf
```

## Before you begin

### Network

| Source              | Destination                                 | Port | Protocol |
| ------------------- | ------------------------------------------- | ---- | -------- |
| OctoXLabs connector | Cloudflare API (default api.cloudflare.com) | 443  | HTTPS    |

### Required permissions

| Scope or role                     | Permission | Needed for             |
| --------------------------------- | ---------- | ---------------------- |
| Zone: Read                        | Read       | Zones                  |
| Firewall Services Read (or Write) | Read       | WAF packages and rules |

## Create credentials in Cloudflare WAF

{% stepper %}
{% step %}

### Open API tokens

For a user token, go to **My Profile > API Tokens** in the Cloudflare dashboard. For an account token, go to **Manage Account > API Tokens**.
{% endstep %}

{% step %}

### Create the token

Select **Create Token** and give it the **Zone: Read** permission and **Firewall Services Read** (or **Firewall Services Write**).
{% endstep %}

{% step %}

### Copy the token

Copy the secret to a secure place.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter    | Required | Type             | Default                      | Description                                                             |
| ------------ | -------- | ---------------- | ---------------------------- | ----------------------------------------------------------------------- |
| Domain       | No       | Text             | <https://api.cloudflare.com> | Base URL of the Cloudflare API.                                         |
| Token        | Yes      | Password         |                              | Cloudflare API token.                                                   |
| Proxy        | No       | Text             |                              | Proxy URL.                                                              |
| Thread Count | No       | Number (1 to 32) | 32                           | Parallel threads for API requests.                                      |
| Sleep Time   | No       | Number (min 0)   | None                         | Delay in seconds between thread batches. Raise it on rate limit errors. |
| Timeout      | No       | Number           | 30                           | Seconds to wait for API responses.                                      |

## Troubleshooting

| Error message                | Cause                               | Fix                                           |
| ---------------------------- | ----------------------------------- | --------------------------------------------- |
| Max retries exceeded for ... | HTTP 429 persisted after 5 retries. | Wait, raise Sleep Time or lower Thread Count. |

## Change history

{% hint style="info" %}
Available starting from version 6.5.3.
{% endhint %}
