Skip to content

cvzero89/cf-update-waf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ Cloudflare WAF Rule Manager

A Python-based tool to manage Cloudflare WAF custom rules using the official cloudflare-python SDK. The tool allows or blocks requests based on the request URI path and source IP address.


โš™๏ธ Features

  • โœ… Create or update WAF custom rules
  • โœ… Match wildcard URI paths (e.g., /admin/*)
  • โœ… Allow access only to specific IPs or ranges
  • โœ… Block all other requests
  • โœ… Supports multiple rules via YAML config
  • โœ… Dry-run mode for safe testing
  • โœ… Uses API token securely via .env file

๐Ÿ› ๏ธ Setup

1. Clone the repository

git clone https://github.com/your-user/cloudflare-waf.git
cd cloudflare-waf

2. Create a virtual environment (optional but recommended)

python3 -m venv venv
source venv/bin/activate

3. Install dependencies

pip3 install -r requirements.txt

4. Create a .env and populate the config.yaml

Create a .env file in the root of the project:

You can generate an API Token from your Cloudflare dashboard. Make sure it includes permission for Zone > Firewall Services > Edit.

5. Run the script

If dry_run: true, the script will show what it would do.

Set dry_run: false to apply changes to Cloudflare.

About

Update WAF Rules dynamically

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages